Mam napisaną akcję, która obsługuje dwa formularze.
Jeden się nie wyświetla choć wszystko wygląda dobrze..
Proszę pomóżcie bo już wysiadam...

UserController.php
public function editAction() { $auth = Zend_Auth::getInstance(); $identity = $auth->getIdentity(); if ($identity) { $form1 = new Application_Form_EditProfile(); $form1->setAction($this->view->url()); $form2 = new Application_Form_ChangePassword(); $form2->setAction($this->view->url()); if ($this->_request->isPost() && $this->_getParam('submitform1') && $form1->isValid($this->_request->getParams())) { $users = new Application_Model_DbTable_Users(); 'mail' => $identity->mail, 'imie' => $identity->imie, 'nazwisko' => $identity->nazwisko, 'data_ur' => $identity->data_ur, 'miejscowosc' => $identity->miejscowosc )); $post = $this->getRequest()->getPost(); } if ($post && $form1->isValid($post)) { $rows = $users->find($identity->users_id); if ($rows->count()) { $user = $rows->current(); $user->setFromArray($post)->save(); $auth->clearIdentity(); $adapter = new Zend_Auth_Adapter_DbTable (null, 'users', 'nazwa', 'users_id'); $adapter->setIdentity($user->nazwa); $adapter->setCredential($user->users_id); $result = $auth->authenticate($adapter); if ($result->isValid()) { $auth->getStorage()->write($data); } $this -> getHelper('viewRenderer') -> setNoRender(true); return; } } $this->view->EditProfileform= $form1; } elseif ($this->_request->isPost() && $this->_getParam('submitform2') && $form2->isValid($this->_request->getParams())) { $User = new Application_Model_DbTable_Users(); $select = $User->select()->where('nazwa = ?', $auth->getIdentity()); $u = $User->fetchRow($select); $this->_helper->viewRenderer('edit'); if ($u && $form2->isValid($this->getRequest()->getPost())) { $haslo = $form2->getValue('haslo'); $salt = Application_My_Salt::getSalt(); $u->salt = $salt; $u->haslo = sha1($salt . $haslo); $u->save(); $mail = new Application_My_Mail_Gmail(); $mail->mailChangePassword($u->mail, $haslo, $auth->getIdentity()); return $this->_helper->redirector('index', 'index', 'default'); } $this->view->ChangePasswordform = $form2; } } else { $this -> getHelper('viewRenderer') -> setNoRender(true); return; } }
EditProfile.php
<?php class Application_Form_EditProfile extends Zend_Form { public function init() { $this->setMethod('post'); $this->addElement( 'text', 'mail', 'label' => 'E-mail', 'required' => true, ), )), array(Zend_Validate_EmailAddress::INVALID => 'Wpisany adres e-mail jest niepoprawny', Zend_Validate_EmailAddress::INVALID_FORMAT => 'Wpisany adres e-mail jest niepoprawny' ))), ), ) ); //Imię $this->addElement( 'text', 'imie', 'label' => 'Imię', 'required' => true, ))), ) ); //Nazwisko $this->addElement( 'text', 'nazwisko', 'label' => 'Nazwisko', 'required' => true, ))), ) ); //Data urodzenia $this->addElement( 'text', 'data_ur', 'label' => 'Rok urodzenia', 'required' => false, ) ); $this->data_ur->getValidator('Int')->setMessages(array(Zend_Validate_Int::NOT_INT => "'%value%' nie jest poprawnym numerem roku")); //Miejscowość $this->addElement( 'text', 'miejscowosc', 'label' => 'Miejscowość', 'required' => false, ) ); //Przycisk rejestracji $this->addElement( 'submit', 'submitform1', 'label' => 'Zapisz zmiany', 'class' => 'btn btn-primary' ) ); } }
ChangePassword.php
<?php class Application_Form_ChangePassword extends Zend_Form { public function init() { $this->setMethod('post'); //Nowe hasło $this->addElement( 'password', 'haslo', 'label' => 'Nowe hasło', 'required' => true, )), 'stringLengthTooLong' => 'Hasło musi składać się z maksymalnie 20 znaków', ) )), ), ) ); //Powtórz nowe hasło $this->addElement( 'password', 'haslo_confirm', 'label' => 'Powtórz nowe hasło', 'required' => true, )), )), ), ) ); //Przycisk zmiany hasła $this->addElement( 'submit', 'submitform2', 'label' => 'Zmień hasło', 'class' => 'btn btn-primary' ) ); } }
Widok
<?php echo $this->EditProfileform; ?> <script type="text/javascript"> function ne(o){ if(document.getElementById(o).style.display=='') document.getElementById(o).style.display = 'none'; else document.getElementById(o).style.display=''; } </script> <br> <div onclick="ne('o1')" class="btn btn-link"> </div> <div id="o1" style="display:none;"> <?php echo $this->ChangePasswordform; ?> </div>