Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [ZF] Zend_form i Display Groups
matias
post
Post #1





Grupa: Zarejestrowani
Postów: 17
Pomógł: 0
Dołączył: 3.10.2004

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


Czy ktoś może mi wyjaśnić czy taki kod jest poprawny ponieważ tworzy mi formularz lecz bez elementów <form></form>

Mam klasę (tylko fragment dla zobrazowania przykładu)
  1. <?php
  2. class User_CreateForm extends Zend_Form 
  3. { 
  4. public function __construct($options = null) 
  5. {  
  6. parent::__construct($options);
  7. $this ->setName('createForm')
  8. ->setAction('create')
  9. ->setAttrib('id', 'publicform');
  10.  
  11. $username  = new Zend_Form_Element_Text('username');
  12. $username ->setLabel('Login:')
  13. ->addValidator('NotEmpty')
  14. ->setRequired(true);
  15.  
  16. $email  = new Zend_Form_Element_Text('email');
  17. $email ->setLabel('Adres email:')
  18. ->addValidator('NotEmpty')
  19. ->addValidator('EmailAddress')
  20. ->setRequired(true);
  21.  
  22. $submit = new Zend_Form_Element_Image('submit');
  23. $submit ->setAttrib('class', 'login-btn')
  24. ->setAttrib('id', 'login-btn')
  25. ->setImage('../public/images/btn.gif'); 
  26.  
  27. $this->addElements(array($username, $email, $submit));
  28.  
  29. $this->addDisplayGroup(array('username', 'email'), 'subForm1st');
  30.  
  31. $this->setDisplayGroupDecorators( array(
  32. array('FormElements'),
  33. array('HtmlTag'),
  34. 'Form'
  35. ));
  36. }
  37. }
  38. ?>


W kontrolerze kod wysyłający formularz do szablonu

  1. <?php
  2. $createForm = new User_CreateForm();
  3.  
  4. $this->view->titlePage = "Rejestracja użytkownika w systemie";
  5. $this->view->titleSection = "Rejestracja";
  6.  
  7. $this->view->form1 = $createForm->subForm1st;
  8. ?>


I wyświetlam wszystko w szablonie
  1. <?php
  2. echo $this->form;
  3. ?>


W wyniku dostaję cały formularz ale niestety bez <form> </form> Czy ja coś robię nie tak?
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: 21.08.2025 - 08:26