Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [Symfony] Problem z walidacją pola password
parzol
post
Post #1





Grupa: Zarejestrowani
Postów: 135
Pomógł: 1
Dołączył: 7.05.2005

Ostrzeżenie: (0%)
-----


Witam!

O to mój formularz:

  1. <?php
  2. class RegistrationForm extends UserForm {
  3.    public function configure() {
  4.        $this->setWidgets(array(
  5.            'login' => new sfWidgetFormInput(array(), array('class' => 'text')),
  6.            'pass' => new sfWidgetFormInputPassword(array(), array('class' => 'text')),
  7.            'repass' => new sfWidgetFormInputPassword(array(), array('class' => 'text')),
  8.            'email' => new sfWidgetFormInput(array(), array('class' => 'text')),
  9.            'country_id' => new sfWidgetFormPropelSelect(array('model' => 'Country', 'add_empty' => false), array('class' => 'text')),
  10.            'culture' => new sfWidgetFormSelectRadio(array('choices' => Culture::getLanguagesWithFlags()), array('class' => 'radio'))
  11.        ));
  12.        
  13.        $this->setDefaults(array(
  14.            'culture' => Culture::getCode()
  15.        ));
  16.        
  17.        $this->setValidators(array(
  18.            'login' => new sfValidatorString(array('required' => true, 'min_length' => 3, 'max_length' => 32), array('required' => sfContext::getInstance()->getI18N()->__('Field required.'))),
  19.            'pass' => new sfValidatorString(array('required' => true, 'min_length' => 3, 'max_length' => 32)),
  20.            'repass' => new sfValidatorString(array('required' => true, 'min_length' => 3, 'max_length' => 32)),
  21.            'email' => new sfValidatorEmail(array(), array('required' => sfContext::getInstance()->getI18N()->__('Field required.'))),
  22.            'country_id' => new sfValidatorString(array('required' => true)),
  23.            'culture' => new sfValidatorString(array('required' => true)),
  24.            'code' => new sfValidatorString(array('required' => true)),
  25.            'created_at' => new sfValidatorInteger(array('required' => true))
  26.        ));
  27.        
  28.        $this->validatorSchema->setPostValidator(new sfValidatorAnd(
  29.            array(
  30.                new sfValidatorSchemaCompare('repass', '==', 'pass', array(), array('invalid' => 'Different passwords')),
  31.                new sfValidatorPropelUnique(array('model' => 'User', 'column' => 'login'), array('invalid' => 'Login in use')),
  32.                new sfValidatorPropelUnique(array('model' => 'User', 'column' => 'email'), array('invalid' => 'E-mail in use'))
  33.            )
  34.        ));
  35.  
  36.        $this->widgetSchema->setNameFormat('data[%s]');
  37.        $this->widgetSchema->getFormFormatter()->setTranslationCatalogue('form');
  38.    }
  39. }
  40. ?>


Walidacja formularza działa. Nawet poprawnie sprawdza mi czy hasła są takie same. Jednak nie pokazuje błędów required i min_length dla pól pass i repass (IMG:http://forum.php.pl/style_emoticons/default/blinksmiley.gif) Dlaczego? Co robię źle? (IMG:http://forum.php.pl/style_emoticons/default/sad.gif)


Z góry dzięki za pomoc. Pozdrawiam.
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 22.08.2025 - 19:08