Zend framework checkbox issue

Hi The problem with Zend_Form_Element_Checkbox is that when it is created, a hidden input field is created with the same name as the actual flag. So let's see the code:

This is how I create an element inside a form:

    $onlineCheckbox = $this->createElement('checkbox', 'online_checkbox', array(
      'label'=>'Online:',
      'uncheckedValue'=> '0',
      'checkedValue' => '1'
    ));

And this outputs html like:

<input type="hidden" name="online_checkbox" value="0" /><input type="checkbox" name="online_checkbox" id="online_checkbox" value="1" />

Now the problem is that in other browsers, then Firefox, I get the desired results through the post (if "0" is not marked, if "1" is checked), but in Firefox for both cases I get "0", I know that it is because of this hidden field. I googled and it seems that this question is not clarified. So my question is how do others deal with this, or maybe there is a solution to make this work in firefox. Any help would be appreciated. Thanks in advance.

EDIT: @Marcin - , . Firebug , , , , @Marcin !

+5
2

, , Dojo. Zend_Dojo_View_Helper_CheckBox . :

$onlineCheckbox = new Zend_Form_Element_CheckBox('online_checkbox', array(
  'label'=>'Online:',
  'uncheckedValue'=> '0', //can be removed, this is the default functionality
  'checkedValue' => '1', //can be removed, this is the default functionality
));

Zend_Form:: createElement().

!

+2

IdenticalValidator:

->addValidator('Identical', false, '1');
+1

All Articles