Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [Symfony]Porównanie haseł w formularzu, symfony 1.4
Mgorka
post
Post #1





Grupa: Zarejestrowani
Postów: 209
Pomógł: 3
Dołączył: 6.04.2010
Skąd: Słupca

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


Witajcie pisze formularz do rejestracji chce porównać pola z hasłami czy są takie same. Czy mógł by mi ktoś wytłumaczyć jak to ustalić w walidatorze? piszę w symfony 1.4 Kod:
  1. <?php
  2.  
  3. class RejestracjaForm extends BaseForm
  4. {
  5.  
  6. public function configure()
  7. {
  8. $this->setWidgets(array(
  9. 'login' => new sfWidgetFormInputText(array('label' => 'Login')),
  10. 'email' => new sfWidgetFormInputText(array('label' => 'Email')),
  11. 'haslo' => new sfWidgetFormInputPassword(array('label' => 'Hasło')),
  12. 'haslo2' => new sfWidgetFormInputPassword(array('label' => 'Powtórz hasło')),
  13. ));
  14. $this->widgetSchema->setNameFormat('rejestracja[%s]');
  15. $this->mergePostValidator(new sfValidatorSchemaCompare('haslo', sfValidatorSchemaCompare::EQUAL, 'haslo2', array(), array('invalid' => 'Oba hasła muszą być takie same.')));
  16. $this->setValidators(array(
  17. 'login' => new sfValidatorString(array('required' => true), array('required' => 'Pole jest wymagane')),
  18. 'email' => new sfValidatorEmail(array(), array('invalid' => 'Wpisz prawidłowy adres','required' => 'Pole jest wymagane')),
  19. 'haslo' => new sfValidatorString(array('required' => true), array('required' => 'Pole jest wymagane')),
  20. 'haslo2' => new sfValidatorString(array('required' => true), array('required' => 'Pole jest wymagane')),
  21. ));
  22. }
  23. }


Ten post edytował Mgorka 19.03.2012, 16:00:45
Go to the top of the page
+Quote Post

Posty w temacie


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 - 20:18