public function init() { $this->setMethod('post'); $user = new Default_Model_User(); $user->find(); $this->addElement('password', 'old_password', array('label' => 'Old password', 'required' => true, 'class' => 'text', 'validators' => array(new OpenId_Validate_MatchOldPassword($user)))); $this->addElement('password', 'password', array('label' => 'Password', 'required' => true, 'validators' => array(array('StringLength', false, 6)), 'class' => 'text')); $this->addElement('password', 'password_confirm', array('label' => 'Confirm password', 'required' => true, 'class' => 'text', 'validators' => array(new OpenId_Validate_MatchField('password')))); $this->addElement('submit', 'submit', array('ignore' => true, 'label' => 'Update')); $this->setDecorators(array('FormElements', array('HtmlTag', array('tag' => 'fieldset')), array('Description', array('placement' => 'prepend', 'class' => 'error')), 'Form')); }
public function passwordAction() { $this->view->headTitle("Change Password", 'PREPEND'); $request = $this->getRequest(); $form = new Default_Form_UserPassword(); if ($this->getRequest()->isPost()) { if ($form->isValid($request->getPost())) { $model = new Default_Model_User(); $user = $model->find(); $user->setPassword($form->getValue("password")); $user->save(); } else { $form->setDescription("Sorry, your password could not be changed. Please check for errors below."); } } $this->view->form = $form; }