Ejemplo n.º 1
0
 public function __construct(EntityRepository $repository)
 {
     parent::__construct('signup');
     $this->filter = new InputFilter();
     $email = new Element\Email('email');
     $email->setAttribute('required', true);
     $email->setAttribute('placeholder', 'Email Address');
     $this->add($email);
     $emailFilter = new Input('email');
     $emailFilter->setRequired(true);
     $emailFilter->getValidatorChain()->attach(new DoctrineValidator\NoObjectExists(array('message' => 'Email address already in use', 'object_repository' => $repository, 'fields' => 'email')));
     $this->filter->add($emailFilter);
     $password = new Element\Password('password');
     $password->setAttribute('required', true);
     $password->setAttribute('placeholder', 'Password');
     $this->add($password);
     $passwordFilter = new Input('password');
     $passwordFilter->setRequired(true);
     $passwordFilter->getFilterChain()->attach(new Filter\StringTrim());
     $passwordFilter->getValidatorChain()->attach(new AppValidator\PasswordStrength());
     $this->filter->add($passwordFilter);
     $confirmPassword = new Element\Password('confirmPassword');
     $confirmPassword->setAttribute('required', true);
     $confirmPassword->setAttribute('placeholder', 'Confirm Password');
     $this->add($confirmPassword);
     $confirmPasswordFilter = new Input('confirmPassword');
     $confirmPasswordFilter->setRequired(true);
     $confirmPasswordFilter->getFilterChain()->attach(new Filter\StringTrim());
     $confirmPasswordFilter->getValidatorChain()->attach(new Validator\Identical('password'));
     $this->filter->add($confirmPasswordFilter);
     $firstName = new Element\Text('firstName');
     $firstName->setAttribute('required', true);
     $firstName->setAttribute('placeholder', 'First Name');
     $this->add($firstName);
     $firstNameFilter = new Input('firstName');
     $firstNameFilter->setRequired(true);
     $firstNameFilter->getFilterChain()->attach(new AppFilter\TitleCase());
     $firstNameFilter->getFilterChain()->attach(new Filter\StringTrim());
     $firstNameFilter->getFilterChain()->attach(new Filter\StripTags());
     $firstNameFilter->getValidatorChain()->attach(new Validator\StringLength(array('max' => 35)));
     $firstNameFilter->getValidatorChain()->attach(new LocaleValidator\Alpha(array('allowWhiteSpace' => true)));
     $this->filter->add($firstNameFilter);
     $lastName = new Element\Text('lastName');
     $lastName->setAttribute('required', true);
     $lastName->setAttribute('placeholder', 'Last Name');
     $this->add($lastName);
     $lastNameFilter = new Input('lastName');
     $lastNameFilter->setRequired(true);
     $lastNameFilter->getFilterChain()->attach(new AppFilter\TitleCase());
     $lastNameFilter->getFilterChain()->attach(new Filter\StringTrim());
     $lastNameFilter->getFilterChain()->attach(new Filter\StripTags());
     $lastNameFilter->getValidatorChain()->attach(new Validator\StringLength(array('max' => 35)));
     $lastNameFilter->getValidatorChain()->attach(new LocaleValidator\Alpha(array('allowWhiteSpace' => true)));
     $this->filter->add($lastNameFilter);
     $street = new Element\Text('street');
     $street->setAttribute('required', true);
     $street->setAttribute('placeholder', 'Street Address');
     $this->add($street);
     $streetFilter = new Input('street');
     $streetFilter->setRequired(true);
     $streetFilter->getFilterChain()->attach(new Filter\StringTrim());
     $streetFilter->getFilterChain()->attach(new Filter\StripTags());
     $streetFilter->getValidatorChain()->attach(new Validator\StringLength(array('max' => 50)));
     $this->filter->add($streetFilter);
     $city = new Element\Text('city');
     $city->setAttribute('required', true);
     $city->setAttribute('placeholder', 'City');
     $this->add($city);
     $cityFilter = new Input('city');
     $cityFilter->setRequired(true);
     $cityFilter->getFilterChain()->attach(new Filter\StringTrim());
     $cityFilter->getFilterChain()->attach(new Filter\StripTags());
     $cityFilter->getValidatorChain()->attach(new Validator\StringLength(array('max' => 30)));
     $this->filter->add($cityFilter);
     $state = new Element\Text('state');
     $state->setAttribute('required', true);
     $state->setAttribute('placeholder', 'State');
     $this->add($state);
     $stateFilter = new Input('state');
     $stateFilter->setRequired(true);
     $stateFilter->getFilterChain()->attach(new Filter\StringTrim());
     $stateFilter->getFilterChain()->attach(new Filter\StripTags());
     $stateFilter->getFilterChain()->attach(new Filter\StringToUpper());
     $stateFilter->getValidatorChain()->attach(new Validator\StringLength(array('min' => 2, 'max' => 2)));
     $this->filter->add($stateFilter);
     $postalCode = new Element\Text('postalCode');
     $postalCode->setAttribute('required', true);
     $postalCode->setAttribute('placeholder', 'Postal Code');
     $this->add($postalCode);
     $postalCodeFilter = new Input('postalCode');
     $postalCodeFilter->setRequired(true);
     $postalCodeFilter->getFilterChain()->attach(new Filter\StringTrim());
     $postalCodeFilter->getFilterChain()->attach(new Filter\StripTags());
     $this->filter->add($postalCodeFilter);
     $phone = new AppElement\Phone('phone');
     $phone->setAttribute('required', true);
     $phone->setAttribute('placeholder', 'Phone Number');
     $this->add($phone);
     $phoneFilter = new Input('phone');
     $phoneFilter->setRequired(true);
     $this->filter->add($phoneFilter);
     $website = new Element\Url('website');
     $website->setAttribute('placeholder', 'Website');
     $this->add($website);
     $websiteFilter = new Input('website');
     $websiteFilter->setRequired(false);
     $this->filter->add($websiteFilter);
     $submit = new Element\Submit('submit');
     $submit->setAttribute('class', 'btn-primary pull-right');
     $submit->setOption('glyphicon', 'user');
     $submit->setLabel('Sign Up');
     $this->add($submit);
 }
Ejemplo n.º 2
0
 public function __construct(EntityRepository $repository)
 {
     parent::__construct('apply');
     $this->filter = new InputFilter();
     $primary = new Element\Hidden('primary');
     $this->add($primary);
     $primaryFilter = new Input('primary');
     $primaryFilter->getValidatorChain()->attach(new DoctrineValidator\NoObjectExists(array('message' => 'Member already owns an affiliate', 'object_repository' => $repository, 'fields' => 'primary')));
     $this->filter->add($primaryFilter);
     $name = new Element\Text('name');
     $name->setAttribute('required', true);
     $name->setAttribute('placeholder', 'Organization Name');
     $this->add($name);
     $nameFilter = new Input('name');
     $nameFilter->setRequired(true);
     $nameFilter->getFilterChain()->attach(new AppFilter\TitleCase());
     $nameFilter->getFilterChain()->attach(new Filter\StringTrim());
     $nameFilter->getFilterChain()->attach(new Filter\StripTags());
     $nameFilter->getValidatorChain()->attach(new Validator\StringLength(array('max' => 80)));
     $nameFilter->getValidatorChain()->attach(new DoctrineValidator\NoObjectExists(array('message' => 'Name already in use', 'object_repository' => $repository, 'fields' => 'name')));
     $this->filter->add($nameFilter);
     $street = new Element\Text('street');
     $street->setAttribute('required', true);
     $street->setAttribute('placeholder', 'Street Address');
     $this->add($street);
     $streetFilter = new Input('street');
     $streetFilter->setRequired(true);
     $streetFilter->getFilterChain()->attach(new Filter\StringTrim());
     $streetFilter->getFilterChain()->attach(new Filter\StripTags());
     $streetFilter->getValidatorChain()->attach(new Validator\StringLength(array('max' => 50)));
     $this->filter->add($streetFilter);
     $city = new Element\Text('city');
     $city->setAttribute('required', true);
     $city->setAttribute('placeholder', 'City');
     $this->add($city);
     $cityFilter = new Input('city');
     $cityFilter->setRequired(true);
     $cityFilter->getFilterChain()->attach(new Filter\StringTrim());
     $cityFilter->getFilterChain()->attach(new Filter\StripTags());
     $cityFilter->getValidatorChain()->attach(new Validator\StringLength(array('max' => 30)));
     $this->filter->add($cityFilter);
     $state = new Element\Text('state');
     $state->setAttribute('required', true);
     $state->setAttribute('placeholder', 'State');
     $this->add($state);
     $stateFilter = new Input('state');
     $stateFilter->setRequired(true);
     $stateFilter->getFilterChain()->attach(new Filter\StringTrim());
     $stateFilter->getFilterChain()->attach(new Filter\StripTags());
     $stateFilter->getFilterChain()->attach(new Filter\StringToUpper());
     $stateFilter->getValidatorChain()->attach(new Validator\StringLength(array('min' => 2, 'max' => 2)));
     $this->filter->add($stateFilter);
     $postalCode = new Element\Text('postalCode');
     $postalCode->setAttribute('required', true);
     $postalCode->setAttribute('placeholder', 'Postal Code');
     $this->add($postalCode);
     $postalCodeFilter = new Input('postalCode');
     $postalCodeFilter->setRequired(true);
     $postalCodeFilter->getFilterChain()->attach(new Filter\StringTrim());
     $postalCodeFilter->getFilterChain()->attach(new Filter\StripTags());
     $this->filter->add($postalCodeFilter);
     $phone = new AppElement\Phone('phone');
     $phone->setAttribute('required', true);
     $phone->setAttribute('placeholder', 'Phone Number');
     $this->add($phone);
     $phoneFilter = new Input('phone');
     $phoneFilter->setRequired(true);
     $this->filter->add($phoneFilter);
     $email = new Element\Email('email');
     $email->setAttribute('required', true);
     $email->setAttribute('placeholder', 'Email Address');
     $this->add($email);
     $emailFilter = new Input('email');
     $emailFilter->setRequired(true);
     $this->filter->add($emailFilter);
     $website = new Element\Url('website');
     $website->setAttribute('placeholder', 'Website');
     $this->add($website);
     $websiteFilter = new Input('website');
     $websiteFilter->setRequired(false);
     $this->filter->add($websiteFilter);
     $buttons = new Form('buttons');
     $buttons->setOption('twb-layout', 'inline');
     $buttons->setAttribute('class', 'form-group');
     $submit = new Element\Submit('submit');
     $submit->setAttribute('class', 'btn-primary pull-right');
     $submit->setOption('glyphicon', 'circle-arrow-up');
     $submit->setLabel('Apply');
     $buttons->add($submit);
     $cancel = new Element\Submit('cancel');
     $cancel->setAttribute('formnovalidate', true);
     $cancel->setAttribute('class', 'btn-warning pull-right');
     $cancel->setOption('glyphicon', 'ban-circle');
     $cancel->setLabel('Cancel');
     $buttons->add($cancel);
     $this->add($buttons);
 }