Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [sfForm] Sprawdzanie haseł
Forum PHP.pl > Forum > PHP > Frameworki
phpion
Cześć,
nie mogę sobie poradzić ze sprawdzeniem, czy podane w formularzu hasła są identyczne. Moja klasa formularza:
  1. <?php
  2. class UserForm extends BaseUserForm {
  3. public function configure() {
  4. $this->setWidgets(array(
  5. 'id' => new sfWidgetFormInputHidden(),
  6. 'email' => new sfWidgetFormInput(),
  7. 'pass' => new sfWidgetFormInputPassword(),
  8. 'repass' => new sfWidgetFormInputPassword(),
  9. 'name' => new sfWidgetFormInput()
  10. ));
  11.  
  12. $this->widgetSchema->setLabels(array(
  13. 'email' => 'Adres e-mail',
  14. 'pass' => 'Hasło',
  15. 'repass' => 'Powtórz hasło',
  16. 'name' => 'Imię'
  17. ));
  18.  
  19. $this->setValidators(array(
  20. 'id' => new sfValidatorPropelChoice(array('model' => 'User', 'column' => 'id', 'required' => false)),
  21. 'email' => new sfValidatorEmail(),
  22. 'pass' => new sfValidatorString(array('min_length' => 5)),
  23. 'repass' => ?,
  24. 'code' => new sfValidatorString(array('min_length' => 32, 'max_length' => 32)),
  25. ));
  26.  
  27. $this->validatorSchema['email']->setMessages(array(
  28. 'required' => 'Pole e-mail jest wymagane',
  29. 'invalid' => 'Podany adres e-mail jest niepoprawny'
  30. ));
  31. $this->validatorSchema['pass']->setMessages(array(
  32. 'required' => 'Hasło jest wymagane',
  33. 'invalid' => 'Podane hasło jest złeee'
  34. ));
  35.  
  36. $this->widgetSchema->setFormFormatterName('list');
  37. $this->widgetSchema->setNameFormat('user[%s]');
  38. }
  39. }
  40. ?>

Nie wiem za bardzo jak to ugryźć. Na forum Symfony znalazłem info:
http://www.symfony-project.org/forum/index.php/m/53890/
ale coś nie bardzo to chce działać :/

Korzystam z Symfony 1.1.0-RC2

Proszę o pomoc,
pion
destroyerr
A tak próbowałeś?
  1. <?php
  2. $this->setValidators(array(
  3. 'id' => new sfValidatorPropelChoice(array('model' => 'User', 'column' => 'id', 'required' => false)),
  4. 'email' => new sfValidatorEmail(),
  5. 'pass' => new sfValidatorString(array('min_length' => 5)),
  6. 'repass' => new sfValidatorString(array('min_length' => 5)),
  7. 'code' => new sfValidatorString(array('min_length' => 32, 'max_length' => 32)),
  8. ));
  9. $this->validatorSchema->setPostValidator(new sfValidatorSchemaCompare('pass', '==', repass));
  10. ?>
phpion
Działa! Dzięki! Wiem skąd to masz tongue.gif http://www.symfony-project.org/book/forms/...Form-Validation wcześniej nie znałem tego linka.
Jeszcze raz dzięki serdeczne.
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.