/**
  * @see sfForm
  */
 public function setup()
 {
     parent::setup();
     $this->widgetSchema['email_address'] = new sfWidgetFormInputEmail(array(), array('placeholder' => '*****@*****.**'));
     $this->widgetSchema['username'] = new sfWidgetFormInputText(array(), array('placeholder' => 'nocoolnametom'));
     $this->widgetSchema['password'] = new sfWidgetFormInputPassword();
     $this->widgetSchema['full_name'] = new sfWidgetFormInputText(array(), array('placeholder' => 'First and last name'));
     $this->widgetSchema['preferred_name'] = new sfWidgetFormInputText(array(), array('placeholder' => 'Bob?'));
     $this->widgetSchema['website'] = new sfWidgetFormInputUrl(array(), array('placeholder' => 'http://nocoolnametom.com/'));
     $this->widgetSchema['twitter_account'] = new sfWidgetFormInputText(array(), array('placeholder' => '@NoCoolName_Tom'));
     $this->widgetSchema['avatar'] = new sfWidgetFormInputUrl();
     $this->widgetSchema['short_bio'] = new sfWidgetFormTextarea(array(), array('placeholder' => 'A bit about yourself...'));
     $this->widgetSchema['address_line_one'] = new sfWidgetFormInputText();
     $this->widgetSchema['address_line_two'] = new sfWidgetFormInputText();
     $this->widgetSchema['city'] = new sfWidgetFormInputText();
     $this->widgetSchema['state'] = new sfWidgetFormSelectUSState();
     $this->widgetSchema['zip_code'] = new sfWidgetFormInputText();
     $this->widgetSchema['country'] = new sfWidgetFormI18nChoiceCountry(array('add_empty' => true));
     $this->widgetSchema['preferred_language'] = new sfWidgetFormI18nChoiceLanguage();
     $this->validatorSchema['country'] = new sfValidatorI18nChoiceCountry();
     $this->validatorSchema['preferred_language'] = new sfValidatorI18nChoiceLanguage();
     unset($this['last_login'], $this['created_at'], $this['updated_at'], $this['salt'], $this['algorithm']);
     $this->widgetSchema['groups_list']->setLabel('Groups');
     $this->widgetSchema['permissions_list']->setLabel('Permissions');
     $this->widgetSchema['password'] = new sfWidgetFormInputPassword();
     $this->validatorSchema['password']->setOption('required', false);
     $this->widgetSchema['password_again'] = new sfWidgetFormInputPassword();
     $this->validatorSchema['password_again'] = clone $this->validatorSchema['password'];
     $this->widgetSchema->moveField('password_again', 'after', 'password');
     $this->mergePostValidator(new sfValidatorSchemaCompare('password', sfValidatorSchemaCompare::EQUAL, 'password_again', array(), array('invalid' => 'The two passwords must be the same.')));
 }
Example #2
0
 public function processValues($values)
 {
     $values = parent::processValues($values);
     if (!sfContext::getInstance()->getUser()->hasCredential('admin')) {
         $values['username'] = $values['email_address'];
     }
     return $values;
 }
 public function configure()
 {
     parent::setup();
     if ($this->isNew()) {
         $this->embedForm('Files', new filesForm());
     } else {
         $this->embedRelation('Files');
     }
     $this->embedRelation('Profile');
     unset($this['last_login'], $this['created_at'], $this['updated_at'], $this['salt'], $this['algorithm'], $this['is_active'], $this['is_super_admin'], $this['groups_list'], $this['permissions_list'], $this['evaluations_list'], $this['username'], $this['email'], $this['Files']);
 }
 public function setup()
 {
     parent::setup();
     $this->useFields(array('password'));
     $this->widgetSchema['password'] = new sfWidgetFormInputPassword();
     $this->validatorSchema['password']->setOption('required', true);
     $this->widgetSchema['password_again'] = new sfWidgetFormInputPassword();
     $this->validatorSchema['password_again'] = clone $this->validatorSchema['password'];
     $this->validatorSchema['password_again']->setOption('required', true);
     $this->mergePostValidator(new sfValidatorSchemaCompare('password', sfValidatorSchemaCompare::EQUAL, 'password_again', array(), array('invalid' => 'The two passwords must be the same.')));
 }
 public function configure()
 {
     parent::configure();
     unset($this['username'], $this['last_login'], $this['created_at'], $this['salt'], $this['algorithm'], $this['is_active'], $this['is_super_admin'], $this['change_password_at'], $this['must_change_password']);
     $this->setWidgets(array('username' => new sfWidgetFormInputHidden(), 'password' => new sfWidgetFormInputPassword(), 'password_new' => new sfWidgetFormInputPassword(), 'password_new_bis' => new sfWidgetFormInputPassword()));
     $password_policy_validator_class = sfConfig::get('app_sf_guard_secure_password_validator', 'sfGuardSecurePasswordValidator');
     $this->setValidators(array('username' => new sfValidatorChoice(array('choices' => array(sfContext::getInstance()->getUser()->getUsername()))), 'password' => new sfValidatorString(array('max_length' => 128)), 'password_new' => new sfValidatorAnd(array(new sfValidatorString(array('max_length' => 128)), new $password_policy_validator_class())), 'password_new_bis' => new sfValidatorString(array('max_length' => 128))));
     $this->getWidgetSchema()->setLabels(array('password' => 'Current', 'password_new' => 'New', 'password_new_bis' => 'Repeat'));
     $this->setDefaults(array('password' => null, 'username' => sfContext::getInstance()->getUser()->getUsername()));
     $this->getWidgetSchema()->setNameFormat('change_password[%s]');
     $this->getValidatorSchema()->setPostValidator(new sfValidatorAnd(array(new sfGuardValidatorUser(array('check_login_failure' => false), array('invalid' => 'Current password is invalid')), new sfValidatorSchemaCompare('password_new', sfValidatorSchemaCompare::EQUAL, 'password_new_bis', array(), array('invalid' => 'The two passwords must be the same.')), new sfValidatorSchemaCompare('password', sfValidatorSchemaCompare::NOT_EQUAL, 'password_new', array(), array('invalid' => "Current and new password can't be the same")))));
 }
 /**
  * @see sfForm
  */
 public function setup()
 {
     parent::setup();
     unset($this['last_login'], $this['created_at'], $this['updated_at'], $this['salt'], $this['algorithm']);
     $this->widgetSchema['groups_list']->setLabel('Groups');
     $this->widgetSchema['permissions_list']->setLabel('Permissions');
     $this->widgetSchema['password'] = new sfWidgetFormInputPassword();
     $this->validatorSchema['password']->setOption('required', false);
     $this->widgetSchema['password_again'] = new sfWidgetFormInputPassword();
     $this->validatorSchema['password_again'] = clone $this->validatorSchema['password'];
     $this->widgetSchema->moveField('password_again', 'after', 'password');
     $this->mergePostValidator(new sfValidatorSchemaCompare('password', sfValidatorSchemaCompare::EQUAL, 'password_again', array(), array('invalid' => 'The two passwords must be the same.')));
 }
 public function updateDefaultsFromObject()
 {
     parent::updateDefaultsFromObject();
     // update defaults for profile
     if (!is_null($profile = $this->getProfile())) {
         $values = $profile->toArray(BasePeer::TYPE_FIELDNAME);
         unset($values[$this->getPrimaryKey()]);
         // update defaults for the main object
         if ($this->isNew) {
             $this->setDefaults(array_merge($values, $this->getDefaults()));
         } else {
             $this->setDefaults(array_merge($this->getDefaults(), $values));
         }
     }
 }
 public function setup()
 {
     parent::setup();
     $this->useFields(array('password'));
     if (true === sfConfig::get('app_sf_guard_user_pssword_hard', true)) {
         $this->validatorSchema['password'] = new sfValidatorRegex(array('pattern' => '/^(?=.*\\d)(?=.*[a-zA-Z]).{8,}$/'));
         $this->validatorSchema['password']->setMessage('invalid', 'A jelszó minimum 8 karakteres, és legalább 1 számot és egy nagy betűt tartalmaz!');
     }
     $this->widgetSchema['password'] = new sfWidgetFormInputPassword();
     $this->validatorSchema['password']->setOption('required', true);
     $this->widgetSchema['password_again'] = new sfWidgetFormInputPassword();
     $this->validatorSchema['password_again'] = clone $this->validatorSchema['password'];
     $this->validatorSchema['password_again']->setOption('required', true);
     $this->mergePostValidator(new sfValidatorSchemaCompare('password', sfValidatorSchemaCompare::EQUAL, 'password_again', array(), array('invalid' => 'The two passwords must be the same.')));
     $this->getWidgetSchema()->getFormFormatter()->setTranslationCatalogue('sf_guard');
 }
 /**
  * @see sfForm
  */
 public function setup()
 {
     parent::setup();
     unset($this['last_login'], $this['created_at'], $this['updated_at'], $this['salt'], $this['algorithm']);
     $this->widgetSchema['groups_list']->setLabel('Groups');
     $this->widgetSchema['permissions_list']->setLabel('Permissions');
     $this->widgetSchema['password'] = new sfWidgetFormInputPassword();
     if (sfConfig::get('app_sf_guard_plugin_hard_pasword', true) == true) {
         $this->validatorSchema['password'] = new sfValidatorRegex(array('pattern' => '/^(?=.*\\d)(?=.*[a-zA-Z]).{8,}$/'));
         $this->validatorSchema['password']->setMessage('invalid', 'A jelszó minimum 8 karakteres, és legalább 1 számot és egy nagy betűt tartalmaz!');
     }
     $this->validatorSchema['password']->setOption('required', false);
     $this->widgetSchema['password_again'] = new sfWidgetFormInputPassword();
     $this->validatorSchema['password_again'] = clone $this->validatorSchema['password'];
     $this->widgetSchema->moveField('password_again', 'after', 'password');
     $this->mergePostValidator(new sfValidatorSchemaCompare('password', sfValidatorSchemaCompare::EQUAL, 'password_again', array(), array('invalid' => 'The two passwords must be the same.')));
 }
 public function configure()
 {
     parent::setup();
     if ($this->isNew()) {
         $this->embedForm('Files', new filesForm());
     } else {
         $this->embedRelation('Files');
     }
     unset($this['last_login'], $this['created_at'], $this['updated_at'], $this['salt'], $this['algorithm'], $this['is_active'], $this['is_super_admin'], $this['groups_list'], $this['permissions_list'], $this['evaluations_list']);
     $this->widgetSchema['password'] = new sfWidgetFormInputPassword();
     $this->validatorSchema['password']->setOption('required', true);
     $this->widgetSchema['password_again'] = new sfWidgetFormInputPassword();
     $this->validatorSchema['password_again'] = clone $this->validatorSchema['password'];
     $this->widgetSchema->moveField('password_again', 'after', 'password');
     $this->mergePostValidator(new sfValidatorSchemaCompare('password', sfValidatorSchemaCompare::EQUAL, 'password_again', array(), array('invalid' => 'The two passwords must be the same.')));
     $this->widgetSchema->setLabels(array('username' => 'Usuario', 'password' => 'Contraseña', 'password_again' => 'Repita el password'));
     $this->embedRelation('Profile');
 }
Example #11
0
 public function bind(array $taintedValues = null, array $taintedFiles = null)
 {
     if (isset($taintedValues['team'])) {
         foreach ($taintedValues['team'] as $i => $team) {
             // When all fields are empty and slot is not the first then slot is not taken into account
             if (!$team['user']['email_address'] && !$team['user']['password']) {
                 $this->validatorSchema['team'][$i]['user']['email_address']->setOption('required', false);
                 $this->validatorSchema['team'][$i]['user']['password']->setOption('required', false);
                 if (!$this['team'][$i]['id']->getValue()) {
                     unset($taintedValues['team'][$i], $this->embeddedForms['team'][$i]);
                 } else {
                     $this->team_members_to_delete_ids[] = $taintedValues['team'][$i]['id'];
                     unset($taintedValues['team'][$i], $this->embeddedForms['team'][$i]);
                 }
             }
         }
     }
     parent::bind($taintedValues, $taintedFiles);
 }
 public function setup()
 {
     parent::setUp();
     $this->setValidator('username', new sfValidatorRegex(array('pattern' => '/^[a-z0-9-]+$/i'), array('invalid' => 'Only a-z, 0-9 or - character')));
 }