Witajcie,
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 (isset($post['mail']) && $post['mail'] != $identity->mail) {
$form1->mail->addValidator('Db_NoRecordExists', true, array('table' => 'users', 'field' => 'mail', 'messages' => array('recordFound' => 'Ten e-mail jest już zajęty'))); }
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()) {
$data = $adapter->getResultRowObject(null, array('haslo', 'salt')); $auth->getStorage()->write($data);
}
$this -> getHelper('viewRenderer') -> setNoRender(true);
echo $this -> view -> render('user/_saveSuccess.phtml'); 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);
echo $this -> view -> render('user/_loginRequired.phtml'); return;
}
}
EditProfile.php
<?php
class Application_Form_EditProfile extends Zend_Form
{
public function init()
{
$this->setMethod('post');
//E-mail
$this->addElement(
'text',
'mail',
'label' => 'E-mail',
'required' => true,
),
array('messages' => array('isEmpty' => 'Proszę wpisać adres e-mail') )),
array('EmailAddress', 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,
'filters' => array('StringTrim'), array('messages' => array('isEmpty' => 'Proszę wpisać imię') ))),
)
);
//Nazwisko
$this->addElement(
'text',
'nazwisko',
'label' => 'Nazwisko',
'required' => true,
'filters' => array('StringTrim'), array('messages' => array('isEmpty' => 'Proszę wpisać nazwisko') ))),
)
);
//Data urodzenia
$this->addElement(
'text',
'data_ur',
'label' => 'Rok urodzenia',
'required' => false,
'validators' => array('Int') )
);
$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,
'filters' => array('StringTrim'), )
);
//Przycisk rejestracji
$this->addElement(
'submit',
'submitform1',
'label' => 'Zapisz zmiany',
'class' => 'btn btn-primary'
)
);
$this->submitform1->setDecorators(array('ViewHelper')); $this->submitform1->addDecorator('HtmlTag', array('tag' => 'dd', 'class' => 'first-button'));
}
}
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,
array('messages' => array('isEmpty'=>'Proszę wpisać nowe hasło i je potwierdzić') )),
array('stringLength', true, array('min' => 3, 'max' => 20, 'messages'=> array('stringLengthTooShort' => 'Hasło musi składać się z co najmniej 3 znaków', '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,
array('messages' => array('isEmpty' => 'Proszę wpisać nowe hasło i je potwierdzić') )),
array('token'=>'haslo', 'messages' => array('notSame' => 'Hasła muszą być takie same') )),
),
)
);
//Przycisk zmiany hasła
$this->addElement(
'submit',
'submitform2',
'label' => 'Zmień hasło',
'class' => 'btn btn-primary'
)
);
$this->submitform2->setDecorators(array('ViewHelper')); $this->submitform2->addDecorator('HtmlTag', array('tag' => 'dd', 'class' => 'first-button')); }
}
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='';
}
<div onclick="ne('o1')" class="btn btn-link"> <div id="o1" style="display:none;"> <?php echo $this->ChangePasswordform; ?>