Пример #1
0
 /**
  * @see sfForm
  */
 public function setup()
 {
     parent::setup();
     unset($this['last_login'], $this['created_at'], $this['updated_at'], $this['salt'], $this['algorithm'], $this['groups_list'], $this['permissions_list'], $this['is_active'], $this['is_super_admin']);
     $this->widgetSchema['password'] = new sfWidgetFormInputPassword(array(), array('autocomplete' => 'off'));
     $this->validatorSchema['password']->setOption('required', $this->object->isNew());
     $this->widgetSchema['password_again'] = new sfWidgetFormInputPassword(array('label' => 'Password (again)'), array('autocomplete' => 'off'));
     $this->validatorSchema['password_again'] = clone $this->validatorSchema['password'];
     $this->widgetSchema->moveField('password_again', 'after', 'password');
     $this->validatorSchema['username'] = new sfValidatorAnd(array($this->validatorSchema['username'], new sfValidatorRegex(array('pattern' => '/^[\\w\\d\\-\\s@\\.]+$/'))));
     $this->changeToEmail('email');
     if ($this->isCaptchaEnabled()) {
         $this->addCaptcha();
     }
     $this->mergePostValidator(new sfValidatorSchemaCompare('password', sfValidatorSchemaCompare::EQUAL, 'password_again', array(), array('invalid' => 'The two passwords must be the same.')));
 }
 /**
  * @see sfForm
  */
 public function setup()
 {
     parent::setup();
     $this->widgetSchema['username'] = new sfWidgetFormInputHidden();
     $this->validatorSchema['username'] = new sfValidatorChoice(array('choices' => array($this->getObject()->username)));
     $this->widgetSchema['old_password'] = new sfWidgetFormInputPassword(array('label' => 'Old password'));
     $this->validatorSchema['old_password'] = new sfValidatorString();
     $this->widgetSchema['password'] = new sfWidgetFormInputPassword(array('label' => 'New password'), array('autocomplete' => 'off'));
     $this->validatorSchema['password']->setOption('required', false);
     $this->widgetSchema['password_again'] = new sfWidgetFormInputPassword(array('label' => 'New password (again)'), array('autocomplete' => 'off'));
     $this->validatorSchema['password_again'] = clone $this->validatorSchema['password'];
     $this->widgetSchema->moveField('password_again', 'after', 'password');
     $this->changeToEmail('email');
     $this->useFields(array('email', 'old_password', 'password', 'password_again'));
     $this->mergePreValidator(new sfValidatorCallback(array('callback' => array($this, 'currentUserValidator'))));
     $userValidator = new dmValidatorUser();
     $userValidator->setOption('password_field', 'old_password');
     $userValidator->setMessage('invalid', 'The password is invalid.');
     $this->mergePostValidator($userValidator);
     $this->mergePostValidator(new sfValidatorSchemaCompare('password', sfValidatorSchemaCompare::EQUAL, 'password_again', array(), array('invalid' => 'The two passwords must be the same.')));
 }
Пример #3
0
 /**
  * @see sfForm
  */
 public function setup()
 {
     parent::setup();
     unset($this['last_login'], $this['created_at'], $this['updated_at'], $this['salt'], $this['algorithm'], $this['forgot_password_code']);
     if (isset($this->widgetSchema['groups_list'])) {
         $this->widgetSchema['groups_list']->setLabel('Groups');
     }
     if (isset($this->widgetSchema['permissions_list'])) {
         $this->widgetSchema['permissions_list']->setLabel('Permissions');
     }
     if ($this->needsWidget('password')) {
         $this->widgetSchema['password'] = new sfWidgetFormInputPassword();
         $this->validatorSchema['password']->setOption('required', $this->object->isNew());
         $this->widgetSchema['password_again'] = new sfWidgetFormInputPassword();
         $this->validatorSchema['password_again'] = clone $this->validatorSchema['password'];
         $this->widgetSchema->moveField('password_again', 'after', 'password');
         $this->validatorSchema['username'] = new sfValidatorAnd(array($this->validatorSchema['username'], new sfValidatorRegex(array('pattern' => '/^[\\w\\d\\-\\s@\\.]+$/'))));
         $this->mergePostValidator(new sfValidatorSchemaCompare('password', sfValidatorSchemaCompare::EQUAL, 'password_again', array(), array('invalid' => 'The two passwords must be the same.')));
     }
     if ($this->needsWidget('email')) {
         $this->changeToEmail('email');
     }
 }