Browse Source

ContactForm model

euromark 14 years ago
parent
commit
bd49d8f99f
1 changed files with 52 additions and 0 deletions
  1. 52 0
      Model/ContactForm.php

+ 52 - 0
Model/ContactForm.php

@@ -0,0 +1,52 @@
+<?php
+
+/**
+ * "Fake" model to validate all contact forms
+ * @author Mark Scherer
+ * @cakephp 2.0
+ * @license MIT
+ * 2011-12-15 ms
+ */
+class ContactForm extends ToolsAppModel {
+
+	protected $_schema = array(
+		'name' => array('type' => 'string' , 'null' => false, 'default' => '', 'length' => '30'),
+		'email' => array('type' => 'string' , 'null' => false, 'default' => '', 'length' => '60'),
+		'subject' => array('type' => 'string' , 'null' => false, 'default' => '', 'length' => '60'),
+		'message' => array('type' => 'text' , 'null' => false, 'default' => ''),
+	);
+	
+	public $useTable = false;
+	
+	public $validate = array(
+		'name' => array(
+			'notEmpty' => array(
+				'rule' => array('notEmpty'),
+				'message' => 'valErrMandatoryField',
+				'last' => true
+			)
+		),
+		'email' => array(
+			'email' => array(
+				'rule' => array('email', true),
+				'message' => 'valErrInvalidEmail',
+				'last' => true
+			),
+		), 
+		'subject' => array(
+			'notEmpty' => array(
+				'rule' => array('notEmpty'),
+				'message' => 'valErrMandatoryField',
+				'last' => true
+			)
+		), 
+		'message' => array(
+			'notEmpty' => array(
+				'rule' => array('notEmpty'),
+				'message' => 'valErrMandatoryField',
+				'last' => true
+			)
+		),
+	);
+
+}