ContactForm.php 1.2 KB

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