PasswordChange.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. /**
  3. */
  4. class Application_Form_PasswordChange extends Zend_Form
  5. {
  6. public function init()
  7. {
  8. $this->setDecorators(array(
  9. array('ViewScript', array('viewScript' => 'form/password-change.phtml'))
  10. ));
  11. $notEmptyValidator = Application_Form_Helper_ValidationTypes::overrideNotEmptyValidator();
  12. $stringLengthValidator = Application_Form_Helper_ValidationTypes::overrideStringLengthValidator(6, 80);
  13. $this->addElement('password', 'password', array(
  14. 'label' => _('Password'),
  15. 'required' => true,
  16. 'filters' => array('stringTrim'),
  17. 'validators' => array($notEmptyValidator,
  18. $stringLengthValidator),
  19. 'decorators' => array(
  20. 'ViewHelper'
  21. )
  22. ));
  23. $this->addElement('password', 'password_confirm', array(
  24. 'label' => _('Confirm new password'),
  25. 'required' => true,
  26. 'filters' => array('stringTrim'),
  27. 'validators' => array(
  28. new Zend_Validate_Callback(function ($value, $context) {
  29. return $value == $context['password'];
  30. }),
  31. ),
  32. 'errorMessages' => array(_("Password confirmation does not match your password.")),
  33. 'decorators' => array(
  34. 'ViewHelper'
  35. )
  36. ));
  37. $this->addElement('submit', 'submit', array(
  38. 'label' => _('Get new password'),
  39. 'ignore' => true,
  40. 'class' => 'ui-button ui-widget ui-state-default ui-button-text-only center',
  41. 'decorators' => array(
  42. 'ViewHelper'
  43. )
  44. ));
  45. }
  46. }