public function configure()
 {
     parent::configure();
     $this->useFields($this->getUseFields());
     $this->widgetSchema->setNameFormat('sfApplySettings[%s]');
     $this->widgetSchema->setFormFormatterName('list');
     $this->widgetSchema->setLabels(array('fullname' => 'Full Name'));
 }
 public function configure()
 {
     parent::configure();
     unset($this['updated_at'], $this['role'], $this['phone'], $this['theme'], $this['is_public']);
     $this->widgetSchema['culture'] = new sfWidgetFormPlopI18nChoiceLanguage(array('languages' => sfPlop::get('sf_plop_cultures'), 'default' => $this->getOption('user_culture'), 'culture' => $this->getOption('culture')));
     $this->widgetSchema->setHelps(array('password' => null));
     $this->validatorSchema['password'] = new sfValidatorString(array('min_length' => 6, 'max_length' => 128));
 }
 public function configure()
 {
     parent::configure();
     // We're making a new user or editing the user who is
     // logged in. In neither case is it appropriate for
     // the user to get to pick an existing userid. The user
     // also doesn't get to modify the validate field which
     // is part of how their account is verified by email.
     unset($this['user_id']);
     $this->useFields(array('username', 'first_name', 'last_name', 'password', 'email_address'));
     // Add username and password fields which we'll manage
     // on our own. Before you ask, I experimented with separately
     // emitting, merging or embedding a form subclassed from
     // sfGuardUser. It was vastly more work in every instance.
     // You have to clobber all of the other fields (you can
     // automate that, but still). If you use embedForm you realize
     // you've got a nested form that looks like a
     // nested form and an end user looking at that and
     // saying "why?" If you use mergeForm you can't save(). And if
     // you output the forms consecutively you have to manage your
     // own transactions. Adding two fields to the profile form
     // is definitely simpler.
     $this->widgetSchema['password2'] = new sfWidgetFormInputPassword(array(), array('maxlength' => 128));
     $this->widgetSchema['email2'] = new sfWidgetFormInputText();
     $this->widgetSchema['password'] = new sfWidgetFormInputPassword(array(), array('maxlength' => 128, 'required' => true));
     $this->widgetSchema->moveField('username', sfWidgetFormSchema::FIRST);
     $this->widgetSchema->moveField('first_name', sfWidgetFormSchema::AFTER, 'username');
     $this->widgetSchema->moveField('last_name', sfWidgetFormSchema::AFTER, 'first_name');
     $this->widgetSchema->moveField('password', sfWidgetFormSchema::AFTER, 'last_name');
     $this->widgetSchema->moveField('password2', sfWidgetFormSchema::AFTER, 'password');
     $this->widgetSchema->moveField('email_address', sfWidgetFormSchema::AFTER, 'password2');
     $this->widgetSchema->moveField('email2', sfWidgetFormSchema::AFTER, 'email_address');
     $this->widgetSchema->setLabels(array('password2' => 'Confirm Password'));
     $this->widgetSchema->setLabels(array('email2' => 'Confirm Email'));
     $this->widgetSchema->setNameFormat('sfApplyApply[%s]');
     //$this->widgetSchema->setFormFormatterName('list');
     // Passwords are never printed - ever - except in the context of Symfony form validation which has built-in escaping.
     // So we don't need a regex here to limit what is allowed
     // Don't print passwords when complaining about inadequate length
     $this->setValidator('password2', new sfValidatorString(array('required' => true, 'trim' => true, 'min_length' => 6, 'max_length' => 128), array('min_length' => 'That password is too short. It must contain a minimum of %min_length% characters.')));
     // Be aware that sfValidatorEmail doesn't guarantee a string that is preescaped for HTML purposes.
     // If you choose to echo the user's email address somewhere, make sure you escape entities.
     // <, > and & are rare but not forbidden due to the "quoted string in the local part" form of email address
     // (read the RFC if you don't believe me...).
     $this->setValidator('email2', new sfValidatorEmail(array('required' => true, 'trim' => true)));
     $this->getValidator('email_address')->setMessage('invalid', 'The email address is not a valid address or an account with that email address already exists. If you have forgotten your password, click "cancel", then "Reset My Password."');
     $schema = $this->validatorSchema;
     // Hey Fabien, adding more postvalidators is kinda verbose!
     $postValidator = $schema->getPostValidator();
     $postValidators = array(new sfValidatorSchemaCompare('password', sfValidatorSchemaCompare::EQUAL, 'password2', array(), array('invalid' => 'The passwords did not match.')), new sfValidatorSchemaCompare('email_address', sfValidatorSchemaCompare::EQUAL, 'email2', array(), array('invalid' => 'The email addresses did not match.')));
     if ($postValidator) {
         $postValidators[] = $postValidator;
     }
     $this->validatorSchema->setPostValidator(new sfValidatorAnd($postValidators));
 }
 public function configure()
 {
     parent::configure();
     // To add your own fields, override sfApplyApplyForm with your own project-level version in which you
     // return a more generous result for getUseFields. This approach prevents the problem
     // of unexpected fields appearing when sfGuardUser's list of relations grows in
     // places you're not thinking about consciously
     $this->useFields($this->getUseFields());
     // useFields doesn't touch hidden fields
     unset($this['id']);
     // We're making a new user or editing the user who is
     // logged in. In neither case is it appropriate for
     // the user to get to pick an existing userid. The user
     // also doesn't get to modify the validate field which
     // is part of how their account is verified by email.
     $this->setWidget('username', new sfWidgetFormInput(array(), array('maxlength' => 16)));
     $this->setWidget('password', new sfWidgetFormInputPassword(array(), array('maxlength' => 128)));
     $this->setWidget('password2', new sfWidgetFormInputPassword(array(), array('maxlength' => 128)));
     $this->widgetSchema->moveField('password2', sfWidgetFormSchema::AFTER, 'password');
     $email = $this->getWidget('email_address');
     $class = get_class($email);
     $this->setWidget('email2', new $class(array(), array('maxlength' => $email->getAttribute('maxlength'))));
     $this->widgetSchema->moveField('email2', sfWidgetFormSchema::AFTER, 'email_address');
     $this->widgetSchema->setLabels(array('password2' => 'Confirm Password', 'email2' => 'Confirm Email'));
     $this->widgetSchema->setNameFormat('sfApplyApply[%s]');
     // We have the right to an opinion on these fields because we
     // implement at least part of their behavior. Validators for the
     // rest of the user object come from the schema and from the
     // developer's form subclass
     $this->setValidator('username', new sfValidatorAnd(array(new sfValidatorString(array('required' => true, 'trim' => true, 'min_length' => 4, 'max_length' => 16)), new sfValidatorRegex(array('pattern' => '/^\\w+$/'), array('invalid' => 'Usernames must contain only letters, numbers and underscores.')), new sfValidatorDoctrineUnique(array('model' => 'sfGuardUser', 'column' => 'username'), array('invalid' => 'There is already a user by that name. Choose another.')))));
     // Passwords are never printed - ever - except in the context of Symfony form validation which has built-in escaping.
     // So we don't need a regex here to limit what is allowed
     // Don't print passwords when complaining about inadequate length
     $this->setValidator('password', new sfValidatorString(array('required' => true, 'trim' => true, 'min_length' => 6, 'max_length' => 128), array('min_length' => 'That password is too short. It must contain a minimum of %min_length% characters.')));
     $this->setValidator('password2', new sfValidatorString(array('required' => true, 'trim' => true, 'min_length' => 6, 'max_length' => 128), array('min_length' => 'That password is too short. It must contain a minimum of %min_length% characters.')));
     // Be aware that sfValidatorEmail doesn't guarantee a string that is preescaped for HTML purposes.
     // If you choose to echo the user's email address somewhere, make sure you escape entities.
     // <, > and & are rare but not forbidden due to the "quoted string in the local part" form of email address
     // (read the RFC if you don't believe me...).
     $this->setValidator('email_address', new sfValidatorAnd(array(new sfValidatorEmail(array('required' => true, 'trim' => true)), new sfValidatorString(array('required' => true, 'max_length' => 80)), new sfValidatorDoctrineUnique(array('model' => 'sfGuardUser', 'column' => 'email_address'), array('invalid' => 'An account with that email address already exists. If you have forgotten your password, click "cancel", then "Reset My Password."')))));
     $this->setValidator('email2', new sfValidatorEmail(array('required' => true, 'trim' => true)));
     $schema = $this->validatorSchema;
     // Hey Fabien, adding more postvalidators is kinda verbose!
     $postValidator = $schema->getPostValidator();
     $postValidators = array(new sfValidatorSchemaCompare('password', sfValidatorSchemaCompare::EQUAL, 'password2', array(), array('invalid' => 'The passwords did not match.')), new sfValidatorSchemaCompare('email_address', sfValidatorSchemaCompare::EQUAL, 'email2', array(), array('invalid' => 'The email addresses did not match.')));
     $this->validatorSchema->setPostValidator(new sfValidatorAnd($postValidators));
 }
 public function configure()
 {
     // Remove all widgets we don't want to show
     unset($this['is_active'], $this['is_super_admin'], $this['updated_at'], $this['groups_list'], $this['permissions_list'], $this['last_login'], $this['created_at'], $this['salt'], $this['algorithm']);
     parent::configure();
     $profileForm = new ProfileForm($this->object->Profile);
     unset($profileForm['id'], $profileForm['sf_guard_user_id']);
     $this->embedForm('Profile', $profileForm);
     //$this->mergForm
     // Setup proper password validation with confirmation
     $this->widgetSchema['password'] = new sfWidgetFormInputPassword();
     $this->validatorSchema['password']->setOption('required', true);
     $this->widgetSchema['password_confirmation'] = new sfWidgetFormInputPassword();
     $this->validatorSchema['password_confirmation'] = clone $this->validatorSchema['password'];
     $this->widgetSchema->moveField('password_confirmation', 'after', 'password');
     $this->mergePostValidator(new sfValidatorSchemaCompare('password', sfValidatorSchemaCompare::EQUAL, 'password_confirmation', array(), array('invalid' => 'The two passwords must be the same.')));
 }
 public function configure()
 {
     parent::configure();
     $this->removeFields();
     /*
         // We're editing the user who is logged in. It is not appropriate
         // for the user to get to pick somebody else's userid, or change
         // the validate field which is part of how their account is
         // verified by email. Also, users cannot change their email
         // addresses as they are our only verified connection to the user.
     
     
             $this->setWidget( 'username',
                     new sfWidgetFormInput( array(), array( 'maxlength' => 16 ) ) );
             $this->widgetSchema->moveField('username', sfWidgetFormSchema::FIRST);
     
     
             //Firstname and lastname
             $this->setWidget( 'firstname', new sfWidgetFormInputText( array(), array( 'maxlength' => 30 ) ) );
             $this->widgetSchema->moveField('firstname', sfWidgetFormSchema::AFTER, 'username');
             $this->setWidget( 'lastname', new sfWidgetFormInputText( array(), array( 'maxlength' => 70 ) ) );
             $this->widgetSchema->moveField('lastname', sfWidgetFormSchema::AFTER, 'firstname');
     
     
             $this->widgetSchema->setLabels( array(
                 'username' => 'Username',
                 'firstname' => 'First Name',
                 'lastname' => 'Last name'
             ) );
     
     
         $this->setValidator( 'firstname' , new sfValidatorApplyFirstname(array('required' => false), array('message' => 'fdsaddfas')) );
         $this->setValidator( 'lastname', new sfValidatorApplyLastname() );
     $this->setValidator( 'username', new sfValidatorSpreadlyUsername() );
     */
     $this->setValidators(array('first_name' => new sfValidatorApplyFirstname(array('required' => true), array('required' => 'firstname required')), 'last_name' => new sfValidatorApplyLastname(array('required' => true), array('required' => 'firstname required')), 'username' => new sfValidatorSpreadlyUsername(array('required' => true), array('required' => 'firstname required'))));
     $this->widgetSchema->setNameFormat('sfApplySettings[%s]');
     $this->widgetSchema->setFormFormatterName('table');
 }
Example #7
0
 public function configure()
 {
     parent::configure();
     $this->setDefault('phone', '+7');
     $this->useFields(array('first_name', 'last_name', 'email_address', 'icq', 'jabber', 'phone'));
 }
 public function configure()
 {
     parent::configure();
     $this->useFields(array('first_name', 'last_name', 'email_address', 'api_key'));
 }
 public function configure()
 {
     parent::configure();
     $this->useFields(array('list_max_per_page'));
 }
 public function configure()
 {
     parent::configure();
     unset($this['groups_list'], $this['permissions_list'], $this['is_active'], $this['is_super_admin'], $this['username']);
 }
 public function configure()
 {
     parent::configure();
     $this->widgetSchema->getFormFormatter()->setTranslationCatalogue('plopAdmin');
     $this->widgetSchema->getFormFormatter()->setHelpFormat(sfPlop::get('sf_plop_form_help_format'));
 }