[html-formfu] 'default_empty_value' doesn't work
Juergen Mathwich
jux at 4950.net
Fri Oct 31 08:30:37 GMT 2008
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
Bye, Juergen
Am Freitag 31 Oktober 2008 08:44:27 schrieb Michele Beltrame:
> Hi Juergen!
>
> > shows me that it is empty, not 0 as expected:
> >
> > 'ACTIVE' => '',
>
> I think this is the expected behaviour: the field is empty as opposed to
> undefined. If you want it become 0 you could add a transformer to your
> checkboxes.
>
> Or, maybe, default_empty_value could be extended and become something
> like default_if_unchecked => 'val'.
>
> Hope this helps.
>
> Michele.
More information about the HTML-FormFu
mailing list