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

Form element Checkbox

I have some problems setting a checkbox bind with an entity.

I want my checkbox value to 1 (true) and the checkbox is checked only if the value in model is true. but whatever the value in the model, the checkbox will be checked, and the value will be 1 or nothing (0) depending the entity value.

that's quite problematicin many situation.

here is my checkbox definition

        $visibility = new Check(self::VISIBILITY);

in the controller I search for my entity and I do a $form->setEntity($entity) to bind the values. all of them worked (I had to did a manual trick to populate multi select though), but checkboxes donesn't work at all.

there should be a setValue on Check Element to set the value, and check it if the value match with the default/entity's value.

I don't know how i could quickly fix this.


setting attribute value worked ...

I don't think it's really an intuitive way but that works.