ContactForm.php 1.2 KB

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