Guest User

Untitled

a guest
Jul 18th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. class BaseCustomForm extends BaseFormDoctrine
  2. {
  3.  
  4. $this->setValidators(array(
  5. .....
  6. 'employer_postcode' => new sfValidatorString(array('max_length' => 10, 'required' => false)),
  7. ....
  8.  
  9.  
  10. class CustomForm extends BaseIncomeInformationForm
  11. {
  12. ......
  13.  
  14. $this->validatorSchema['employer_postcode'] = new sfValidatorOr(array(
  15. new UKPostCodeValidator(),
  16. $this->validatorSchema['employer_postcode'],
  17. ));
  18.  
  19. ......
  20.  
  21.  
  22. class UKPostCodeValidator extends sfValidatorRegex
  23. {
  24. protected function configure($options = array(), $messages = array())
  25. {
  26. parent::configure($options, $messages);
  27.  
  28. $this->setOption('pattern', '/^([A-PR-UWYZ0-9][A-HK-Y0-9][AEHMNPRTVXY0-9]?[ABEHMNPRVWXY0-9]? {1,2}[0-9][ABD-HJLN-UW-Z]{2}|GIR 0AA)$/');
  29. }
  30. }
Add Comment
Please, Sign In to add comment