Guest User

Untitled

a guest
Mar 2nd, 2018
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.80 KB | None | 0 0
  1. <?php
  2. class Model_Form_Login extends Zend_Form
  3. {
  4. protected $_actionUrl;
  5.  
  6. public function __construct($actionUrl = null, $options=null)
  7. {
  8. parent::__construct($options);
  9. $this->setActionUrl($actionUrl);
  10. $this->init();
  11. }
  12.  
  13. public function setActionUrl($actionUrl)
  14. {
  15. $this->_actionUrl = $actionUrl;
  16. return $this;
  17. }
  18.  
  19. public function init()
  20. {
  21. $this->setAction($this->_actionUrl)
  22. ->setMethod('post')
  23. ->setAttrib('id', 'login-form');
  24.  
  25. $this->setDisableLoadDefaultDecorators(true);
  26.  
  27. $this->setDecorators(
  28. array(
  29. 'FormElements', array(
  30. 'HtmlTag', array(
  31. 'tag' => 'fieldset'
  32. )
  33. ),
  34. 'Form'
  35. )
  36. );
  37.  
  38. $decorators = array(
  39. array('ViewHelper'),
  40. array('Errors'),
  41. array('Label', array(
  42. 'class' => 'left-aligned'
  43. )),
  44. array('HtmlTag', array(
  45. 'tag' => 'div',
  46. 'class' => 'field'
  47. ))
  48. );
  49.  
  50. $this->addElementPrefixPath('JobTracking_Validate', 'JobTracking/Validate/', 'validate');
  51.  
  52. $empty = new Zend_Validate_NotEmpty();
  53. $empty->setMessage('Ahhhhh! I am empty!');
  54.  
  55. $this->addElement('hidden', 'redirectUrl');
  56. $redirectUrl = $this->getElement('redirectUrl');
  57. $redirectUrl->clearDecorators();
  58.  
  59. $this->addElement('text', 'username', array('label' => 'Username'));
  60. $username = $this->getElement('username')
  61. ->addValidator($empty, true)
  62. ->addValidator('alnum')
  63. ->setRequired(true, true)
  64. ->addFilter('StringTrim')
  65. ->addValidator('EmployeeAuthorise');
  66. $username->getValidator('alnum')->setMessage(
  67. 'Quit putting funky characters in your username! We only accept letters and numbers.');
  68. $username->setDecorators($decorators);
  69.  
  70. $this->addElement('password', 'password', array('label' => 'Password'));
  71. $password = $this->getElement('password')
  72. ->addValidator($empty, true)
  73. ->setRequired(true, true)
  74. ->addFilter('StringTrim');
  75. $password->setDecorators($decorators);
  76.  
  77. $submit = $this->addElement('button', 'login', array('label' => 'Login'));
  78.  
  79. // tried this: $submit->removeDecorator('DtDdWrapper');
  80.  
  81. // and this: $submit->setDisableLoadDefaultDecorators(true);
  82.  
  83. }
  84. }
Add Comment
Please, Sign In to add comment