We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Checkbox issues

Hi,

I think I've found a couple of bugs using Phalcon 1.2.3 on Windows:

When using Phalcon\Tag::checkField with a value of 0, the resulting HTML checkbox is always returned with a checked="checked" attribute:

echo '<label>';
echo \Phalcon\Tag::checkField(array('test', 'value' => 0)); 
echo 'Zero</label>';

//generates unwanted checked="checked":

<label><input type="checkbox" value="0" name="test" checked="checked" />Zero</label>

Also, Phalcon\Tag::setDefaults() has no effect when wanting to set as "checked" multiple checkboxes. Using Phalcon\Tag::setDefault() is not satisfactory as only one of the checkboxes can be set as checked.

This is fixed in 1.2.4 and 1.3.0.



3.2k
edited Mar '14

Hi,

actually the last point is not solved:

Also, Phalcon\Tag::setDefaults() has no effect when wanting to set as "checked" multiple checkboxes. Using Phalcon\Tag::setDefault() is not satisfactory as only one of the checkboxes can be set as checked.

When using multiple checkboxes, we can only set one value for all the group. Ex:

$this->tag->checkField("checkboxes[]", "value" => 1);
$this->tag->checkField("checkboxes[]", "value" => 2);
$this->tag->checkField("checkboxes[]", "value" => 3);

Actually even if the values come from $_POST, the checkboxes don't pick the values from it.

I guess this is the same for all other multiple fields.

Thx a lot