Consultez la FAQ sur le ZF avant de poster une question
Vous n'êtes pas identifié.
Bonjour,
je suis en train de terminer le tutoriel de Rob allen de site developpez et j'ai cette erreur lorsque je clique le lien supprimer :
Fatal error: Uncaught exception 'Zend_Controller_Action_Exception' with message 'Action "supprimer" does not exist and was not trapped in __call()' in C:\xampp\htdocs\zf-tutoriel\library\Zend\Controller\Action.php:477 Stack trace: #0 C:\xampp\htdocs\zf-tutoriel\library\Zend\Controller\Action.php(504): Zend_Controller_Action->__call('supprimerAction', Array) #1 C:\xampp\htdocs\zf-tutoriel\library\Zend\Controller\Dispatcher\Standard.php(293): Zend_Controller_Action->dispatch('supprimerAction') #2 C:\xampp\htdocs\zf-tutoriel\library\Zend\Controller\Front.php(914): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http)) #3 C:\xampp\htdocs\zf-tutoriel\index.php(27): Zend_Controller_Front->dispatch() #4 {main} thrown in C:\xampp\htdocs\zf-tutoriel\library\Zend\Controller\Action.php on line 477
merci d'avance
Hors ligne
Salut,
Pour pouvoir t'aider, il nous faudrait au moins le code de tes scripts...
Mais à première vue, tu as omis de créer une fonction "supprimerAction" dans ton contrôleur.
Dernière modification par acharrex (26-09-2008 19:39:38)
Hors ligne
Merci acharrex
j'ai cree une fonction de supprimerAction()
et viola le code de script de supprimer
<html>
<head>
<title><?php echo $this->escape($this->title); ?></title>
</head>
<body>
<h1><?php echo $this->escape($this->title); ?></h1>
<?php if ($this->album) :?>
<p>Êtes-vous sûr de vouloir supprimer
'<?php echo $this->escape($this->album->title); ?>' par
'<?php echo $this->escape($this->album->artist); ?>' ?
</p>
<form action="<?php echo $this->url(array('action'=>'supprimer')); ?>" method="post">
<div>
<input type="hidden" name="id" value="<?php echo $this->album->id; ?>" />
<input type="submit" name="del" value="Oui" />
<input type="submit" name="del" value="Non" />
</div>
</form>
<?php else: ?>
<p>Impossible de trouver l'album.</p>
<?php endif;?>
</body>
</html>
merci d'avance
Hors ligne
Salut,
Tu pourrais juste donner le code de ton contrôleur ?
Hors ligne
Bonjour,
voila le code de IndexController:
<?php
class IndexController extends Zend_Controller_Action
{
function indexAction()
{
$this->view->title = "Mes albums";
$album = new Albums();
$this->view->albums = $album->fetchAll();
}
function ajouterAction()
{
$this->view->title = "Ajouter un nouvel album";
$form = new FormulaireAlbum();
$form->submit->setLabel('Ajouter');
$this->view->form = $form;
if ($this->_request->isPost())
{
$formData = $this->_request->getPost();
if ($form->isValid($formData))
{
$albums = new Albums();
$row = $albums->createRow();
$row->artist = $form->getValue('artist');
$row->title = $form->getValue('title');
$row->save();
$this->_redirect('/');
} else
{
$form->populate($formData);
}
}
}
}
function modifierAction()
{
$this->view->title = "Modifier un album";
$form = new FormulaireAlbum();
$form->submit->setLabel('Enregistrer');
$this->view->form = $form;
if ($this->_request->isPost())
{
$formData = $this->_request->getPost();
if ($form->isValid($formData))
{
$albums = new Albums();
$id = (int)$form->getValue('id');
$row = $albums->fetchRow('id='.$id);
$row->artist = $form->getValue('artist');
$row->title = $form->getValue('title');
$row->save();
$this->_redirect('/');
} else
{
$form->populate($formData);
}
} else
{
// L'id de l'album est attendu dans $params['id']
$id = (int)$this->_request->getParam('id', 0);
if ($id > 0)
{
$albums = new Albums();
$album = $albums->fetchRow('id='.$id);
$form->populate($album->toArray());
}
}
}
function supprimerAction()
{
$this->view->title = "Supprimer un album";
if ($this->_request->isPost())
{
$id = (int)$this->_request->getPost('id');
$del = $this->_request->getPost('del');
if ($del == 'Oui' && $id > 0)
{
$albums = new Albums();
$where = 'id = ' . $id;
$albums->delete($where);
}
$this->_redirect('/');
}
else
{
$id = (int)$this->_request->getParam('id');
if ($id > 0) {
$albums = new Albums();
$this->view->album = $albums->fetchRow('id='.$id);
}
}
}
merci d'avance
Hors ligne
Merci pour votre réponse
le probleme ete des accolade j'utilise dreamweaver sachant il contient d'equilibre des accolade mais il detecte pas
Merci beaucoup
Hors ligne
ok parfait, tu peux mettre le topic à résolu .
note: moi aussi j'utilise dreamweaver . Mais avec un peu de rigueur (indentation, toujours ouvrir et fermer accolades avant de mettre le contenu dedans) il n'y a pas de problèmes
.
Hors ligne
Utiliser le bbcode 'code' pour ses codes sources : c'est le bien
Hors ligne