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 checkbox

Hello How can i set a value on checkbox in the form? Phalcon\Forms\Element\Check 1.At the moment i just setup a checkbox, but the value that renders is "On", aand i want to be some integer like 1 or 0 2.The checkbox is not required ,so whats supposed to do in the model when validate ?



79
edited Oct '14
$rememberMe = new Check('remember_me', array(
    'value' => 1,
    'class' => 'box'
));
$this->add($rememberMe);

when you create a new form element you can pass it attributes as array.

https://docs.phalcon.io/en/latest/api/Phalcon_Forms_Element_Check.html

if you don't know how to make form class, check vokuro project

https://github.com/phalcon/vokuro/tree/master/app/forms