Guest User

Untitled

a guest
Apr 11th, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.78 KB | None | 0 0
  1. <?php
  2.  
  3. class accountFormSignup extends sfForm
  4. {
  5. public function configure()
  6. {
  7. $this->setWidgets(array(
  8. 'username' => new sfWidgetFormInput(),
  9. 'email' => new sfWidgetFormInput(),
  10. 'password' => new sfWidgetFormInput(array('type' => 'password')),
  11. 'password_dup' => new sfWidgetFormInput(array('type' => 'password')),
  12. ));
  13.  
  14. $this->widgetSchema->setLabels(array(
  15. "username" => "Username :",
  16. "email" => "Email :",
  17. "password" => "Password :",
  18. 'password_dup' => 'Password again :',
  19. ));
  20. $this->setValidators(array(
  21. 'username' => new sfValidatorAnd(array(
  22. new sfValidatorString(array('required' => true)),
  23. new sfValidatorDoctrineUnique(array(
  24. // check that username is not present in the database
  25. 'model' => 'sfGuardUser',
  26. 'column' => 'username',
  27. 'required' => true
  28. )
  29. )
  30. )
  31. ),
  32. 'email' => new sfValidatorAnd(array(
  33. new sfValidatorEmail(array('required' => true)),
  34. // check that email is not present in the database
  35. new sfValidatorDoctrineUnique(array(
  36. 'model' => 'sfGuardUserProfile',
  37. 'column' => 'email',
  38. 'required' => true
  39. )
  40. ),
  41. )
  42. ),
  43. 'password' => new sfValidatorString(array('required' => true)),
  44. 'password_dup' => new sfValidatorString(array('required' => true)),
  45. ));
  46.  
  47. $this->validatorSchema->setPostValidator(
  48. // to check that password and password_dup are equal
  49. new sfValidatorSchemaCompare('password', sfValidatorSchemaCompare::EQUAL, 'password_dup',
  50. array(),
  51. array('invalid' => 'Both passwords MUST be the same')
  52. )
  53. );
  54. $this->widgetSchema->setNameFormat('signup[%s]');
  55. }
  56. }
Add Comment
Please, Sign In to add comment