[html-formfu] 'default_empty_value' doesn't work

Carl Franks fireartist at gmail.com
Fri Oct 31 08:47:39 GMT 2008


2008/10/31 Juergen Mathwich <jux at 4950.net>:
> Hi Michele
>
> Thanks for your reply.
>
> I read following information from this thread
> http://lists.scsys.co.uk/pipermail/html-formfu/2008-August/001334.html
>
>> If you're using hand-rolled code to update the database - be aware
>> that the browser doesn't send anything back for unchecked checkboxes -
>> not even an empty value - so either your db-update code will need to
>> check the FormFu form object for checkboxes that haven't been
>> submitted, or you'll need to use 'default_empty_value'.
>
>> Carl
>
> This is why i *thought* default_empty_value should set it to "0" (the default
> value) if used.
>
> Regarding your reply I missunderstood the behavior - default_empty_value
> causes process() to add the key to the hash if the box isn't checked, but not
> to set a default value.
>
> Possible solutions are:
>
> 1. run through the result and set unset checkbox values to 0
> 2. use transformers (like you suggested)
> 3. add the suggested "default_if_unchecked" to formfu

Are you using HTML-FormFu-Model-DBIC ?
As long as DBIC is told the field corresponding to the checkbox is not
nullable, it'll take care of this for you, and set it to zero.

Carl



More information about the HTML-FormFu mailing list