|
@@ -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
|
|
|
|
|
+ )
|
|
|
|
|
+ ),
|
|
|
|
|
+ );
|
|
|
|
|
+
|
|
|
|
|
+}
|