konto usunięte
Temat: Problem z formularzem i modułami
Witam Utworzyłem nowy czysty projekt w zendzie poleceniem zf create projekt kalendarz dodałem również poleceniem zf create module admin dodatkowy moduł dla admina oraz uruchomiłem layouty. Wszystko działa jak należy ale mam kilka problemów. 1. Linki do podstron nie działają, albo działają w dziwny sposób np. <a href="Logowanie/login">Zaloguj</a> jeżeli jestem w adresie localhost/admin i klikne w ten link to przekierowuje mnie poprawnie, natomiast jeżeli wrócę na poprzednią stronę to przekierowuje mnie na admin/adminLogowanie/login :/ na dodatek po kliknięciu w formularzu na submit otrzymuje taki błąd (ten kod umiescilem na dole wpisu)An error occurred Page not found Exception information: Message: Action "array" does not exist and was not trapped in __call() Stack trace: #0 C:\xampp\htdocs\kalendarz\library\Zend\Controller\Action.php(515): Zend_Controller_Action->__call('arrayAction', Array) #1 C:\xampp\htdocs\kalendarz\library\Zend\Controller\Dispatcher\Standard.php(295): Zend_Controller_Action->dispatch('arrayAction') #2 C:\xampp\htdocs\kalendarz\library\Zend\Controller\Front.php(954): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http)) #3 C:\xampp\htdocs\kalendarz\library\Zend\Application\Bootstrap\Bootstrap.php(97): Zend_Controller_Front->dispatch() #4 C:\xampp\htdocs\kalendarz\library\Zend\Application.php(366): Zend_Application_Bootstrap_Bootstrap->run() #5 C:\xampp\htdocs\kalendarz\public\index.php(28): Zend_Application->run() #6 {main} Request Parameters: array ( 'module' => 'admin', 'controller' => 'Logowanie', 'action' => 'Array', 'user' => 'asd', 'pass' => 'asd', 'Zaloguj' => 'Zaloguj', )Plik bootstrap mam pusty, w index.php nic nie dodawałem i nie zmieniałem. Kod kontrolera LoginController
<?php
class Admin_LogowanieController extends Zend_Controller_Action {
public function init() {
$this->_helper->layout->setLayout('admin_login_layout');
}
public function indexAction() {
// action body
}
public function loginAction() {
$form = new Kalendarz_Form_Login();
$form->setAction(array('controller'=> 'logowanie','action'=>'login'),'admin',true);
$this->view->form = $form;
if ($this->getRequest()->isPost() && $form->isValid($_POST)) {
$dane = $form->getValues();
$db = Zend_Db_Table::getDefaultAdapter();
$authAdapter = new Zend_Auth_Adapter_DbTable(
$db, 'administrator', 'login', 'haslo');
$authAdapter->setIdentity($dane['user']);
$authAdapter->setCredential($dane['pass']);
$result = $authAdapter->authenticate();
if ($result->isValid()) {
$daneUzytkownika = $authAdapter->getResultRowObject();
Zend_Auth::getInstance()->getStorage()->write($daneUzytkownika);
$this->_helper->redirector('index', 'index');
} else {
$this->view->komunikat = 'Logowanie nieudane';
}
}
}
public function logoutAction() {
// action body
}
}
oraz kod formularza
<?php
class Admin_Kalendarz_Form_Login extends Zend_Form {
public function init() {
$this->setMethod('post');
$user = $this->createElement('text', 'user');
$user->setLabel('Nazwa użytkownika:');
$user->setRequired(true);
$this->addElement($user);
$pass = $this->createElement('password', 'pass');
$pass->setLabel('Hasło:');
$pass->setRequired(true);
$this->addElement($pass);
$this->addElement('submit', 'Zaloguj');
}
}
2. Jak zrobić aby formularze z modułu admin były umieszczone w katalogu admin/forms? 3. Jak poprawić błąd z linkami? z góry dziekuje za pomoc
Kod błędu
Krzysiek Zyk edytował(a) ten post dnia 10.04.11 o godzinie 19:09Krzysiek Zyk edytował(a) ten post dnia 10.04.11 o godzinie 19:10Krzysiek Zyk edytował(a) ten post dnia 10.04.11 o godzinie 19:10
An error occurred
Page not found
Exception information:
Message: Action "array" does not exist and was not trapped in __call()
Stack trace:
#0 C:\xampp\htdocs\kalendarz\library\Zend\Controller\Action.php(515): Zend_Controller_Action->__call('arrayAction', Array)
#1 C:\xampp\htdocs\kalendarz\library\Zend\Controller\Dispatcher\Standard.php(295): Zend_Controller_Action->dispatch('arrayAction')
#2 C:\xampp\htdocs\kalendarz\library\Zend\Controller\Front.php(954): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http))
#3 C:\xampp\htdocs\kalendarz\library\Zend\Application\Bootstrap\Bootstrap.php(97): Zend_Controller_Front->dispatch()
#4 C:\xampp\htdocs\kalendarz\library\Zend\Application.php(366): Zend_Application_Bootstrap_Bootstrap->run()
#5 C:\xampp\htdocs\kalendarz\public\index.php(30): Zend_Application->run()
#6 {main}
Request Parameters:
array (
'module' => 'admin',
'controller' => 'Logowanie',
'action' => 'Array',
'user' => '',
'pass' => '',
'Zaloguj' => 'Zaloguj',
)