Example #1
0
 /**
  * @param object $entity
  * @param array $options
  */
 public function initialize($entity = null, $options = null)
 {
     //Name
     $name = new Text('name', array('placeholder' => 'Full name'));
     $name->setLabel('Name');
     $name->addValidators(array(new PresenceOf(array('message' => 'The name is required')), new StringLength(array('min' => 8, 'messageMinimum' => 'Name is too short. Minimum 8 characters'))));
     $this->add($name);
     //Username
     $username = new Text('login', array('placeholder' => 'Username'));
     $username->addValidators(array(new PresenceOf(array('message' => 'The username is required', 'cancelOnFail' => true)), new StringLength(array('min' => 5, 'messageMinimum' => 'Username is too short. Minimum 5 characters'))));
     $this->add($username);
     //Password
     $password = new Password('password', array('placeholder' => 'Password'));
     $password->addValidators(array(new PresenceOf(array('message' => 'The password is required', 'cancelOnFail' => true)), new StringLength(array('min' => 8, 'messageMinimum' => 'Password is too short. Minimum 8 characters')), new Confirmation(array('message' => 'Password doesn\'t match confirmation', 'with' => 'confirmPassword'))));
     $this->add($password);
     //Confirm Password
     $confirmPassword = new Password('confirmPassword', array('placeholder' => 'Confirm Password', 'cancelOnFail' => true));
     $confirmPassword->addValidators(array(new PresenceOf(array('message' => 'The confirmation password is required'))));
     $this->add($confirmPassword);
     //Remember
     $terms = new Check('terms', array('value' => 'yes'));
     $terms->setLabel('Accept terms and conditions');
     $terms->addValidator(new Identical(array('value' => 'yes', 'message' => 'Terms and conditions must be accepted')));
     $this->add($terms);
     //Sign Up
     $this->add(new Submit('Sign Up', array('class' => 'btn btn-success')));
 }
 public function initialize($entity = null, $options = null)
 {
     $name = new Text('name');
     $name->setLabel('Name');
     $name->addValidators(array(new PresenceOf(array('message' => 'The name is required'))));
     $this->add($name);
     //Email
     $email = new Text('email');
     $email->setLabel('E-Mail');
     $email->addValidators(array(new PresenceOf(array('message' => 'The e-mail is required')), new Email(array('message' => 'The e-mail is not valid'))));
     $this->add($email);
     //Password
     $password = new Password('password');
     $password->setLabel('Password');
     $password->addValidators(array(new PresenceOf(array('message' => 'The password is required')), new StringLength(array('min' => 8, 'messageMinimum' => 'Password is too short. Minimum 8 characters')), new Confirmation(array('message' => 'Password does not match confirmation', 'with' => 'confirmPassword'))));
     $this->add($password);
     //Confirm Password
     $confirmPassword = new Password('confirmPassword');
     $confirmPassword->setLabel('Confirm Password');
     $confirmPassword->addValidators(array(new PresenceOf(array('message' => 'The confirmation password is required'))));
     $this->add($confirmPassword);
     //Remember
     $terms = new Check('terms', array('value' => 'yes'));
     $terms->setLabel('Accept terms and conditions');
     $terms->addValidator(new Identical(array('value' => 'yes', 'message' => 'Terms and conditions must be accepted')));
     $this->add($terms);
     //CSRF
     $csrf = new Hidden('csrf');
     $csrf->addValidator(new Identical(array('value' => $this->security->getSessionToken(), 'message' => 'CSRF validation failed')));
     $this->add($csrf);
     //Sign Up
     $this->add(new Submit('Register', array('class' => 'btn btn-success')));
 }
Example #3
0
 public function initialize($entity = null, $options = null)
 {
     if (isset($options['edit']) && $options['edit']) {
         $id = new Hidden('id');
     } else {
         $id = new Text('id');
     }
     $username = new Text('username', array('placeholder' => 'Tran Duy Thien'));
     //<input type="text" value="" id="fullName" name="fullName">
     $username->setLabel('Tên Tài Khoản');
     //<label for="fullName">fullName</label>
     $username->addValidators(array(new PresenceOf(array('message' => 'Tài khoản không được rỗng'))));
     $this->add($username);
     //Password
     $password = new Password('password');
     $password->setLabel('Mật Khẩu');
     $password->addValidators(array(new PresenceOf(array('message' => 'Mật khẩu không được rỗng')), new StringLength(array('min' => 8, 'messageMinimum' => 'Mật khẩu phải lớn hơn 8 ký tự')), new Confirmation(array('message' => 'Mật khẩu không khớp', 'with' => 'confirmPassword'))));
     $this->add($password);
     //Confirm Password
     $confirmPassword = new Password('confirmPassword');
     $confirmPassword->setLabel('Nhập lại mật khẩu');
     $confirmPassword->addValidators(array(new PresenceOf(array('message' => 'The confirmation password is required'))));
     $this->add($confirmPassword);
     //Remember
     $terms = new Check('terms', array('value' => 'yes'));
     $terms->setLabel('Đồng ý với Điều khoản dịch vụ và chính sách bảo mật của chúng tôi');
     $terms->addValidator(new Identical(array('value' => 'yes', 'message' => 'Bạn chưa chọn')));
     $this->add($terms);
     //CSRF
     $csrf = new Hidden('csrf');
     $csrf->addValidator(new Identical(array('value' => $this->security->getSessionToken(), 'message' => 'CSRF validation failed')));
     $this->add($csrf);
     //Sign Up
     $this->add(new Submit('Sign Up', array('class' => 'btn btn-primary pull-right')));
 }
Example #4
0
 public function initialize($entity = null, $options = null)
 {
     $name = new Text('username');
     $name->setLabel('Name');
     $name->addValidators(array(new PresenceOf(array('message' => 'Username is required')), new Regex(array('pattern' => '/[0-9a-zA-Z_]+/', 'message' => 'Username is alphanumerics and underline only')), new StringLength(array('min' => 4, 'max' => 24, 'messageMinimum' => 'Username is too short. Minimum 4 characters', 'messageMaximum' => 'Username is too long. Maximum 24 characters'))));
     $this->add($name);
     // Email
     $email = new Text('email');
     $email->setLabel('Email');
     $email->addValidators(array(new PresenceOf(array('message' => 'Email is required')), new Email(array('message' => 'Email is not valid'))));
     $this->add($email);
     // Password
     $password = new Password('password');
     $password->setLabel('Password');
     $password->addValidators(array(new PresenceOf(array('message' => 'The password is required')), new StringLength(array('min' => 6, 'max' => 26, 'messageMinimum' => 'Password is too short. Minimum 6 characters', 'messageMaximum' => 'Password is too long. Maximum 26 characters'))));
     $this->add($password);
     // Confirm Password
     /*
     $confirmPassword = new Password('passwordConfirm');
     $confirmPassword->setLabel('Confirm Password');
     $confirmPassword->addValidators(array(
         new PresenceOf(array(
             'message' => 'The confirmation password is required'
         )),
         new Confirmation(array(
             'message' => 'Password doesn\'t match',
             'with' => 'password'
         ))
     ));
     $this->add($confirmPassword);
     */
     // Remember
     $terms = new Check('agree', array('value' => 'yes'));
     $terms->setLabel('Accept terms and conditions');
     $terms->addValidator(new Identical(array('value' => 'yes', 'message' => 'Terms and conditions must be accepted')));
     $this->add($terms);
     /*
     // CSRF
     $csrf = new Hidden('csrf');
     
     $csrf->addValidator(new Identical(array(
         'value' => $this->security->getSessionToken(),
         'message' => 'CSRF validation failed'
     )));
     
     $this->add($csrf);
     
     // Sign Up
     $this->add(new Submit('Sign Up', array(
         'class' => 'btn btn-success'
     )));
     */
 }
Example #5
0
 public function initialize($entity = null, $options = null)
 {
     $name = new Text('name');
     $name->setLabel('Имя');
     $name->addValidators(array(new PresenceOf(array('message' => 'Поле Имя обязательно для заполнения'))));
     $this->add($name);
     //Email
     $email = new Text('email');
     $email->setLabel('E-Mail');
     $email->addValidators(array(new PresenceOf(array('message' => 'Адрес электронной почты обязателен')), new Email(array('message' => 'Не верный адрес электронной почты'))));
     $this->add($email);
     /*
     		//Password
     		$password = new Password('password');
     
     		$password->setLabel('Пароль');
     
     		$password->addValidators(array(
     			new PresenceOf(array('message' => 'Поле пароль обязательно')),
     			new StringLength(array('min' => 8, 'messageMinimum' => 'Пароль слишком короткий. Минимум 8 знаков')),
     			new Confirmation(array('message' => 'Не совпадение в полях паролей', 'with' => 'confirmPassword'))));
     
     		$this->add($password);
     
     		//Confirm Password
     		$confirmPassword = new Password('confirmPassword');
     
     		$confirmPassword->setLabel('Подтвердить пароль');
     
     		$confirmPassword->addValidators(array(new PresenceOf(array('message' => 'Поле подтверждения пароля обязательно'))));
     
     		$this->add($confirmPassword);
     */
     //Remember
     $terms = new Check('terms', array('value' => 'yes', 'class' => 'checkbox'));
     $terms->setLabel('Вы согласны с условиями соглашения');
     $terms->addValidator(new Identical(array('value' => 'yes', 'message' => 'Условия соглашения должны быть приняты')));
     $this->add($terms);
     //CSRF
     $csrf = new Hidden('csrf');
     $csrf->addValidator(new Identical(array('value' => $this->security->getSessionToken(), 'message' => 'сработала защита от CSRF')));
     $this->add($csrf);
     //Sign Up
     $this->add(new Submit('Зарегистрироваться', array('class' => 'btn btn-success')));
 }