I am a Zend Framework beginner. I guess My question is very basic... but I can't solve it by myself.
In indexAction, $request->isPost() is always false. What is happening?
EntryController::indexAction
public function indexAction() { $form = new AgreementForm(); $form->get('submit')->setValue('Go Entry Form'); $request = $this->getRequest(); if ($request->isPost()) { var_dump('//// $request->isPost() is true //////'); if ($form->get('agreementCheck')) { // Redirect to list of entries return $this->redirect()->toRoute('entry'); } else { return array('form' => $form); } } else { var_dump('//// $request->isPost() is false //////'); return array('form' => $form); } } form in index.phtml
<?php $form = $this->form; $form->setAttribute('action', $this->url('entry', array('action' => 'index'))); $form->prepare(); echo $this->form()->openTag($form); echo $this->formCheckbox($form->get('agreementCheck')); echo $this->formSubmit($form->get('submit')); echo $this->form()->closeTag(); ?> AgreementForm is generated using code generator. http://zend-form-generator.123easywebsites.com/formgen/create as below.
class AgreementForm extends Form { public function __construct($name = null) { parent::__construct(''); $this->setAttribute('method', 'post'); $this->add(array( 'name' => 'agreementCheck', 'type' => 'Zend\Form\Element\MultiCheckbox', 'attributes' => array( 'required' => 'required', 'value' => '0', ), 'options' => array( 'label' => 'Checkboxes Label', 'value_options' => array( '0' => 'Checkbox', ), ), )); $this->add(array( 'name' => 'csrf', 'type' => 'Zend\Form\Element\Csrf', )); $this->add(array( 'name' => 'submit', 'attributes' => array( 'type' => 'submit', 'value' => 'Go', 'id' => 'submitbutton', ), )); } } Please tell me some hints.
update: In the result of analysis by Developer Tools, POST and GET works at the same time. 
update: router definition @module.config.php is this.
'router' => array( 'routes' => array( 'entry' => array( 'type' => 'segment', 'options' => array( 'route' => '/entry[/][:action][/:id]', 'constraints' => array( 'action' => '[a-zA-Z][a-zA-Z0-9_-]*', 'id' => '[0-9]+', ), 'defaults' => array( 'controller' => 'Entry\Controller\Entry', 'action' => 'index', ), ), ), 'home' => array( 'type' => 'Zend\Mvc\Router\Http\Literal', 'options' => array( 'route' => '/', 'defaults' => array( 'controller' => 'Entry\Controller\Entry', 'action' => 'index', ), ), ), ), ),