ContactForm.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. App::uses('ToolsAppModel', 'Tools.Model');
  3. /**
  4. * "Fake" model to validate all contact forms
  5. * @author Mark Scherer
  6. * @license http://opensource.org/licenses/mit-license.php MIT
  7. */
  8. class ContactForm extends ToolsAppModel {
  9. protected $_schema = array(
  10. 'name' => array('type' => 'string', 'null' => false, 'default' => '', 'length' => '30'),
  11. 'email' => array('type' => 'string', 'null' => false, 'default' => '', 'length' => '60'),
  12. 'subject' => array('type' => 'string', 'null' => false, 'default' => '', 'length' => '60'),
  13. 'message' => array('type' => 'text', 'null' => false, 'default' => ''),
  14. );
  15. public $useTable = false;
  16. public $validate = array(
  17. 'name' => array(
  18. 'notEmpty' => array(
  19. 'rule' => array('notEmpty'),
  20. 'message' => 'valErrMandatoryField',
  21. 'last' => true
  22. )
  23. ),
  24. 'email' => array(
  25. 'email' => array(
  26. 'rule' => array('email', true),
  27. 'message' => 'valErrInvalidEmail',
  28. 'last' => true
  29. ),
  30. ),
  31. 'subject' => array(
  32. 'notEmpty' => array(
  33. 'rule' => array('notEmpty'),
  34. 'message' => 'valErrMandatoryField',
  35. 'last' => true
  36. )
  37. ),
  38. 'message' => array(
  39. 'notEmpty' => array(
  40. 'rule' => array('notEmpty'),
  41. 'message' => 'valErrMandatoryField',
  42. 'last' => true
  43. )
  44. ),
  45. );
  46. }