Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [sfForm] Sprawdzanie haseł
phpion
post
Post #1





Grupa: Moderatorzy
Postów: 6 072
Pomógł: 861
Dołączył: 10.12.2003
Skąd: Dąbrowa Górnicza




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

Ten post edytował phpion 23.06.2008, 11:08:59
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 2)
destroyerr
post
Post #2





Grupa: Zarejestrowani
Postów: 879
Pomógł: 189
Dołączył: 14.06.2006
Skąd: Bytom

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


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. ?>


Ten post edytował destroyerr 23.06.2008, 11:39:29
Go to the top of the page
+Quote Post
phpion
post
Post #3





Grupa: Moderatorzy
Postów: 6 072
Pomógł: 861
Dołączył: 10.12.2003
Skąd: Dąbrowa Górnicza




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.
Go to the top of the page
+Quote Post

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

 



RSS Aktualny czas: 20.08.2025 - 09:59