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 = new Text('email'); $email->setLabel('E-mail'); $email->addValidators(array(new PresenceOf(array('message' => 'The email is required')), new Email(array('message' => 'The email is not valid')))); $this->add($email); $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); $confirmPassword = new Password('confirmPassword'); $confirmPassword->setLabel('Confirm Password'); $confirmPassword->addValidators(array(new PresenceOf(array('message' => 'The confirmation password is required')))); $this->add($confirmPassword); $terms = new Check('terms', array('value' => 'yes')); $terms->setLabel('Accept terms and conditions'); $terms->addValidators(array(new Identical(array('value' => 'yes', 'message' => 'Terms and conditions must be accepted')))); $this->add($terms); $this->add(new Submit('Sign Up', array('class' => 'btn btn-success'))); }