As an addition to ZF: how to check GET request?.
I have two input fields and one checkbox. The form is standart.
public function init()
{
$this->setMethod('GET');
$new = new Zend_Form_Element_Checkbox('new');
$new->setLabel('New')
->setOrder(3);
$app = new Zend_Form_Element_Select('app');
$app->setLabel('System')
->setOrder(2)
->setRequired()
->addMultiOptions(array('0' => ' ----------- ') + $applications);
$cat = new Zend_Form_Element_Select('cat');
$cat->setLabel('Theme')
->setOrder(1)
->setRequired()
->addMultiOptions(array('0' => ' ----------- ') + $categories);
$submit = new Zend_Form_Element_Submit('submit');
$submit->setLabel('Search')
->setOrder(4);
$this->addElements(array(
$cat, $app, $new, $submit
));
}
1) I do the submit where new is 0: http://site.com/?cat=0&app=0&new=0
2) I do the submit where new is 1: http://site.com/?cat=0&app=0&new=0&new=1
Why the new field has duplication then? I would be good if new=0 is absent if new=1
I think it is because Zend_From creates a hidden input field next to your checkbox. It does it because when checkbox is not checked, by definition, no value associated with the checkbox is being sent to the server. So Zend_Form creates the hidden field to have something sent in case a checkbox is unchecked. However, the drawback is that when the checkbox is checked, two values are sent, i.e. a hidden one and the actual value of checkbox.