Forum

Thread tagged as: Question, Forms

Checkbox Question

Is there a way to make a checkbox "Checked" by default?

Robert Ketter

Robert Ketter 103 points

  • 6 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

In which context?

Forms Template. ie:

<perch:input id="checkbox1" type="checkbox" label="Set Alarm" value="true" checked="checked" />
Drew McLellan

Drew McLellan 2638 points
Perch Support

Sort of, but not a good way. It's actually quite a hard problem. If the box is checked by default, was unchecked by the user, but then the form redisplays with an error, what should the state of that checkbox be? It's not been included in the post, so does that mean it's unchecked, or does that mean it should be checked because that's the default and no value has been set? So yeah.

PerchSystem::set_var('checkbox1', 'true');

When I stop laughing... I will sort this out :)

Thanks so much.