I´m new in ZF2 and I have a problem with reveiving the post/get Parameters in my Controller. Following Exception appears:
Zend\ServiceManager\Exception\ServiceNotFoundException
Zend\Mvc\Controller\PluginManager::get was unable to fetch or create an instance for fromPost
My index.phtml
...
<form id="formActionCl" action="/public/checklistCore/delete" method="post">
<input type="submit" id="butto_doAction<?php echo $index;?>" hidden="true" value="<?php echo $this->translate('button_confirm_action', 'checklist');?>"/>
<input type="hidden" id="checklist" value="<?php echo $index;?>">
</form>
...
And the Controller:
use Zend\Mvc\Controller\Plugin\AbstractPluginManager,
...
public function deleteAction()
{
$cl_id = $this->fromPost('checklist');
echo $cl_id;
//$cl_id = $_GET['checklist'];
$checklist = $this->getEntityManager()->getRepository('ChecklistCore\Entity\Checklist')->find($cl_id);
$checklist->status = 'inactiv';
$this->getEntityManager()->persist($checklist);
$this->getEntityManager()->flush();
return $this->redirect()->toUrl('index');
}
I think I have forgott something in the module.config, but I can´t find anything, how to declare the serviceManager right (module.config.php)
Two changes are needed. First, as Tim wrote, it should be
Second, form items are passed to the controller by name, not id. So in addition to the id field on the element, you need a name field, as follows: