[html-formfu] How to make checkbox (checked/unchecked) database driven

Carl Franks fireartist at gmail.com
Thu Jul 5 17:36:57 GMT 2007


On 05/07/07, kewei xiao <kewei.xiao at nald.ca> wrote:
>
>    In the update of my form, I have a checkbox called 'administrator'.
> I want this checkbox to be checked when the user is administrator,
> otherwise the checkbox stays unchecked.
>
>   So far I have written an customized element which can show the
> checkbox checked, but it stays checked even the user is not administrator.

checkboxes are a little different from other form fields, in that
default() and value() are not simply aliases to each other.

value() is always set - it's the value that the browser returns if the
checkbox is checked.

If the form hasn't been submitted, then the checkbox will only be
rendered checked if default() equals value().
If the form has has been submitted, then the checkbox will be rendered
checked if the submitted value equals value().

If that doesn't clear it up - you'll need to show up your code, for help.

Cheers,
Carl



More information about the HTML-FormFu mailing list