tuto zend framwework non abouti
Salut a tous voila j'ai realiser le tuto Débuter avec Zend Framework voila j'arrive a afficher le controller et mon views fonctionne affiche bdd Album mais quand il s'agit d'ajouter et modifier des nouveaux albums
cela ne fonctionne pas pourtant j'ai bien suivi et ajouter tout dans les views:
voici mon
controller :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
| <?php
class IndexController extends Zend_Controller_Action
{
public function init()
{
/* Initialize action controller here */
}
public function indexAction()
{
$this->view->title = "Mes Albums";
$this->view->headTitle($this->view->title, 'PREPEND');
$albums = new Model_DbTable_Albums();
$this->view->albums = $albums->fetchAll();
}
public function addAction()
{
$this->view->title = "Ajouter un nouvel album";
$this->view->headTitle($this->view->title, 'PREPEND');
$form = new Form_Album();
$form->envoyer->setLabel('Ajouter');
$this->view->form = $form;
if ($this->getRequest()->isPost()) {
$formData = $this->getRequest()->getPost();
if ($form->isValid($formData)) {
$artiste = $form->getValue('artiste');
$titre = $form->getValue('titre');
$albums = new Model_DbTable_Albums();
$albums->ajouterAlbum($artiste, $titre);
$this->_redirect('/');
} else {
$form->populate($formData);
}
}
}
public function editAction()
{
$this->view->title = "Modifier l'album";
$this->view->headTitle($this->view->title, 'PREPEND');
$form = new Form_Album();
$form->envoyer->setLabel('Sauvegarder');
$this->view->form = $form;
if ($this->getRequest()->isPost()) {
$formData = $this->getRequest()->getPost();
if ($form->isValid($formData)) {
$id = (int)$form->getValue('id');
$artiste = $form->getValue('artiste');
$titre = $form->getValue('titre');
$albums = new Model_DbTable_Albums();
$albums->modifierAlbum($id, $artiste, $titre);
$this->_redirect('/');
} else {
$form->populate($formData);
}
} else {
$id = $this->_getParam('id', 0);
if ($id > 0) {
$albums = new Model_DbTable_Albums();
$form->populate($albums->obtenirAlbum($id));
}
}
}
public function deleteAction()
{
$this->view->title = "Supprimer l'album";
$this->view->headTitle($this->view->title, 'PREPEND');
if ($this->getRequest()->isPost()) {
$supprimer = $this->getRequest()->getPost('supprimer');
if ($supprimer == 'Oui') {
$id = $this->getRequest()->getPost('id');
$albums = new Model_DbTable_Albums();
$albums->supprimerAlbum($id);
}
$this->_redirect('/');
} else {
$id = $this->_getParam('id', 0);
$albums = new Model_DbTable_Albums();
$this->view->album = $albums->obtenirAlbum($id);
}
}
} |
application.ini
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
| [production]
phpSettings.display_startup_errors = 0
phpSettings.display_errors = 0
phpSettings.date.timezone = "Europe/Paris"
includePaths.library = APPLICATION_PATH "/../library"
bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
bootstrap.class = "Bootstrap"
appnamespace = "Application"
resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"
resources.layout.layoutpath = APPLICATION_PATH "/layouts"
resources.frontController.params.displayExceptions = 0
[staging : production]
resources.db.adapter = "MYSQLI"
resources.db.params.host = "localhost"
resources.db.params.username = "root"
resources.db.params.password = ""
resources.db.params.dbname = "zftutorial"
resources.db.params.charset = "utf8"
resources.db.isDefaultTableAdapter = true
[testing : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
[development : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
resources.frontController.params.displayExceptions = 1
;
resources.db.adapter = "MYSQLI"
resources.db.params.host = "localhost"
resources.db.params.username = "root"
resources.db.params.password = ""
resources.db.params.dbname = "zftutorial"
resources.db.params.charset = "utf8"
resources.db.isDefaultTableAdapter = true |
ainsi que le Bootstrap:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
| <?php
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
protected function _initAutoload()
{
$moduleLoader = new Zend_Application_Module_Autoloader(array(
'namespace' => '',
'basePath' => APPLICATION_PATH));
return $moduleLoader;
}
protected function _initViewHelpers()
{
$this->bootstrap('layout');
$layout = $this->getResource('layout');
$view = $layout->getView();
$view->doctype('XHTML1_STRICT');
$view->headMeta()->appendHttpEquiv('Content-Type', 'text/html;charset=utf-8');
$view->headTitle()->setSeparator(' - ');
$view->headTitle(' Tutoriel Zend Framework');
}
} |
voila si vous voulez plus de renseignement il ya pas de soucis (merci d'avance votre helpers)
excusez mo de repondre tardivemen
je montre le formulaire a 5h4rk :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
| <?php
class Form_Album extends Zend_Form
{
public function __construct($options = null)
{
parent::__construct($options);
$this->setName('album');
$id = new Zend_Form_Element_Hidden('id');
$artiste = new Zend_Form_Element_Text('artiste');
$artiste->setLabel('Artiste')
->setRequired(true)
->addFilter('StripTags')
->addFilter('StringTrim')
->addValidator('NotEmpty');
$titre = new Zend_Form_Element_Text('titre');
$titre->setLabel('Titre')
->setRequired(true)
->addFilter('StripTags')
->addFilter('StringTrim')
->addValidator('NotEmpty');
$envoyer = new Zend_Form_Element_Submit('envoyer');
$envoyer->setAttrib('id', 'boutonenvoyer');
$this->addElements(array($id, $artiste, $titre, $envoyer));
}
} |
ensuite
voila ce que m'affiche mes erreurs:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| Exception information:
Message: Action "modifier" does not exist and was not trapped in __call()
Stack trace:
#0 C:\wamp\www\zf-tutorial\library\Zend\Controller\Action.php(518): Zend_Controller_Action->__call('modifierAction', Array)
#1 C:\wamp\www\zf-tutorial\library\Zend\Controller\Dispatcher\Standard.php(295): Zend_Controller_Action->dispatch('modifierAction')
#2 C:\wamp\www\zf-tutorial\library\Zend\Controller\Front.php(954): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http))
#3 C:\wamp\www\zf-tutorial\library\Zend\Application\Bootstrap\Bootstrap.php(97): Zend_Controller_Front->dispatch()
#4 C:\wamp\www\zf-tutorial\library\Zend\Application.php(366): Zend_Application_Bootstrap_Bootstrap->run()
#5 C:\wamp\www\zf-tutorial\public\index.php(26): Zend_Application->run()
#6 {main}
Request Parameters:
array (
'controller' => 'index',
'action' => 'modifier',
'id' => '1',
'module' => 'default',
) |
voila c'est la meme erreur pour ajouter,modifier, et supprimer sauf que l'action change