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

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',
)

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
Arkadiusz Burszczan

Arkadiusz Burszczan Programista Java

Temat: Problem z formularzem i modułami

1.poczytaj sobie o BaseUrl
2.w index.php dodaj sobie ścieżkę do admin/forms i wtedy będziesz widział formularze,
np set_include_path(APPLICATION_PATH . '/admin/forms'

konto usunięte

Temat: Problem z formularzem i modułami

2. Do Bootstrap dodałem

protected function _initAutoload() {

$autoLoader = Zend_Loader_Autoloader::getInstance();
$autoLoader->setFallbackAutoloader(true);

// ładowanie modułu admina
$autoloader = new Zend_Application_Module_Autoloader(array(
'namespace' => 'Admin_',
'basePath' => APPLICATION_PATH . '/modules/admin',
'resourceTypes' => array(
'forms' => array('path' => '/modules/admin/forms',
'namespace' => 'Form')
)
)
);
}

ale to nie pomogło
dodałem do index.php include_path

set_include_path(
APPLICATION_PATH . '/admin/forms'.
get_include_path()
);


i teraz otrzymuje taki błąd

Fatal error: Cannot redeclare class Zend_Loader in C:\xampp\htdocs\kalendarz\library\Zend\Loader.php on line 31

tylko nigdzie przeciez nie deklaruje klasy Zend_Loader drugi raz:/

Następna dyskusja:

Zend_DB PDO dziwny problem




Wyślij zaproszenie do