mercredi 2 septembre 2015

How to use checkboxes with Phalcon forms?

I am creating a form using Phalcon that has a checkbox on it. I use this code to create the checkbox in my PagesForm.php file

$this->add(new Check('usesLayout', array('value' => true)));

and then in my view I have

{{ form.render("usesLayout") }}

However, if the checkbox is unchecked then Phalcon complains about usesLayout is required.

The html code produced by the view is

<input type="checkbox" id="usesLayout" name="usesLayout" value="1" checked="checked" />

What is the correct way to create a Phalcon form with a checkbox so that it accepts it both checked and unchecked?




Aucun commentaire:

Enregistrer un commentaire