Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [ZendFramework] layout i zend_form
kociupk
post
Post #1





Grupa: Zarejestrowani
Postów: 97
Pomógł: 1
Dołączył: 29.03.2006

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


zastanawiam sie jak przekazac formularz do layout, odebrac dane i sprawdzic czu uzytkownik jest zalogowany

mam plik indexController ktory przekazuje formularz do helpera
  1. class IndexController extends Zend_Controller_Action
  2. {
  3. function init()
  4. {
  5. $form = new App_Form_Login();
  6. $helper= $this->_helper->getHelper('formlogin');
  7. $helper->formlogin($form);
  8. }
  9. }

plik helper FormLogin

  1. class Zend_View_Helper_FormLogin extends Zend_View_Helper_Abstract
  2. {
  3. private $form;
  4.  
  5. public function formlogin($form)
  6. {
  7. return $form;
  8. }
  9. }

plik bootstrap
  1. protected function _initViewHelper()
  2. {
  3. $this->bootstrap('layout');
  4. $layout = $this->getResource('layout');
  5. $view = $layout->getView();
  6.  
  7. $form = new Zend_View_Helper_FormLogin();
  8. $view = $form->formlogin();
  9. }

nie wiem czy to dziala wszystko pisane z palca chce sie dowiedziec czy mam dobry tok myslenia czy to tak ma mniej wiecej wygladac

Ten post edytował kociupk 10.04.2010, 14:18:51
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
zend
post
Post #2





Grupa: Zarejestrowani
Postów: 580
Pomógł: 85
Dołączył: 25.03.2010
Skąd: Skrzyszów :)

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


  1. $this -> _helper -> layout() -> loginForm = $form
  2. //kod w kontrolerze


  1. <html>
  2. <body>
  3. <div><? echo $this -> layout() -> loginForm; ?></div>
  4. <? echo $this -> layotu() -> content; ?>
  5. </body>
  6. </html>

A druga opcja to
  1. <html>
  2. <body>
  3. <div><? echo $this -> myLoginForm(); //jesli forma masz w helperze, ale mozesz miec problem w przypadku kilku modulow ?></div>
  4. <? echo $this -> layotu() -> content; ?>
  5. </body>
  6. </html>

Trzecia opcja to
  1. protected function _initViewHelper()
  2. {
  3. $this->bootstrap('layout');
  4. $layout = $this->getResource('layout');
  5.  
  6. $form = new Zend_View_Helper_FormLogin();
  7. $layout -> loginForm = $form;
  8. }
  9.  
  10. echo $this -> layout() -> loginForm; //czesc w layoucie


@darko przekazywanie takich formularzy przez kontroler nie jest dobrym pomyslem

Ten post edytował zend 10.04.2010, 16:26:37
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: 4.10.2025 - 02:19