Here is my code:
<?php
class IndexController extends Zend_Controller_Action
{
public function indexAction()
{
$this->_forward('search');
}
public function searchAction()
{
if($this->getRequest()->isGet())
{
$form = $this->getForm();
$value = $form->getValue('search');
echo "'", $value, "'"; // <-- prints ''
}
$this->view->form = $this->getForm();
}
public function getForm()
{
$form = new Zend_Form();
$form->setAction('/index/search')
->setMethod('get');
$search = $form->createElement('text', 'search');
$search->addFilter('StripTags')
->addFilter('StringTrim');
// Add elements to form:
$form->addElement($search)
->addElement('submit', 'submit', array('label' => 'Search'));
return $form;
}
}
In searchAction() $value is always blank even after I submit the form and I see the data in the URL. What is the problem?
EDIT: I fixed getValue() to getValues() but it still isn't working.