Guest User

Untitled

a guest
Dec 10th, 2017
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.68 KB | None | 0 0
  1. public function init()
  2. {
  3. /* Form Elements & Other Definitions Here ... */
  4. $this->setLegend('Client area');
  5. $this->setAttribs(array('id' => 'loginform','class' => 'form','action' => '/auth/login/index'));
  6. $username = new Zend_Form_Element_Text('username');
  7. $username->setAutoInsertNotEmptyValidator(false);
  8. $username->class = 'formText';
  9. $username->setLabel('Username:')
  10. ->addValidator('NotEmpty', true, array('messages' => array(
  11. Zend_Validate_NotEmpty::IS_EMPTY => _('Username is required and cant be empty'),
  12. Zend_Validate_NotEmpty::INVALID => _('Invalid type, contact the administrator')
  13. )))
  14. ->setRequired(true)
  15. ->addFilter('StripTags')
  16. ->addFilter('StringTrim')
  17. ->addFilter('StringToLower', array('UTF-8'))
  18. ->setDecorators(array(
  19. array('ViewHelper',array('helper' => 'formText')),
  20. array('Label',array('class' => 'label')),
  21. array('HtmlTag', array('tag' => 'p', 'class' => 'inline-small-label'))
  22. ));
  23.  
  24. $password = new Zend_Form_Element_Password('password');
  25. $password->setAutoInsertNotEmptyValidator(false);
  26. $password->class = 'formtext';
  27. $password->setLabel('Password:')
  28. ->addValidator('NotEmpty', true, array('messages' => array(
  29. Zend_Validate_NotEmpty::IS_EMPTY => _('Password is required and cant be empty'),
  30. Zend_Validate_NotEmpty::INVALID => _('Invalid type, contact the administrator')
  31. )))
  32. ->setRequired(true)
  33. ->addFilter('StripTags')
  34. ->addFilter('StringTrim')
  35. ->addFilter('StringToLower', array('UTF-8'))
  36. ->setDecorators(array(
  37. array('ViewHelper',array('helper' => 'formPassword')),
  38. array('Label',array('class' => 'label')),
  39. array('HtmlTag', array('tag' => 'p', 'class' => 'inline-small-label'))
  40. ));
  41.  
  42. $token = new Zend_Form_Element_Hash('token', array('salt' => 'Authentication'));
  43. $token->setSalt('s3cr3t-s4lt');
  44. $token->setTimeout(300);
  45. $token->setIgnore(true);
  46. $token->removeDecorator('HtmlTag');
  47. $token->removeDecorator('Label');
  48. $token->addErrorMessage(_('Token provided did not match, session expired. Please reload the form.'));
  49.  
  50.  
  51. $submit = new Zend_Form_Element_Button('Login');
  52. $submit->class = 'float-right';
  53. $submit->setValue('Login')
  54. ->setAttrib('type','submit')
  55. ->setRequired(false)
  56. ->setDecorators(array(
  57. array('ViewHelper',array('helper' => 'formButton')),
  58. ));
  59.  
  60. $remember = new Zend_Form_Element_Checkbox('remember');
  61. $remember->setLabel('Keep me logged in');
  62. $remember->class = 'mini-switch';
  63. $remember->setCheckedValue('1');
  64. $remember->setUncheckedValue('0');
  65. $remember->setChecked(false);
  66. $remember->setDecorators(array(
  67. array('ViewHelper', array('helper' => 'formCheckbox')),
  68. array('Label', array('class' => 'inline', 'placement' => 'append')),
  69. array('HtmlTag', array('tag' => 'p', 'class' => 'input-height'))
  70. ));
  71.  
  72. $this->addElements(array(
  73. $username,
  74. $password,
  75. $token,
  76. $submit,
  77. $remember
  78. ));
  79. }
  80. public function loadDefaultDecorators()
  81. {
  82. $this->setDecorators(array(
  83. 'FormElements',
  84. 'Fieldset',
  85. 'Form',
  86. ));
  87. }
Add Comment
Please, Sign In to add comment