Page 1 of 1
[SOLVED] Form Builder default value for checkbox?
Posted: Wed Apr 24, 2013 2:45 am
by Wishbone
I just discovered the value_FIELDNAME='default value' for Form Builder. This seems to work for text entry, textarea, and radio button, but I can't seem to get it to work for checkbox... I tried '1', 'checked' and 'true' for the default value, but it's not working.
I know that I can set it inside the form, but I want it to be dynamic, based on the current smarty variables.
Any ideas?
Re: Form Builder default value for checkbox?
Posted: Wed Apr 24, 2013 2:48 am
by Jo Morg
It's just a suggestion as I didn't have time test it: why not true or 1 (without the quotes or double quotes)?
Re: Form Builder default value for checkbox?
Posted: Wed Apr 24, 2013 5:14 am
by Wishbone
Yep.. I tried y, yes, checked, true, 1
Re: Form Builder default value for checkbox?
Posted: Wed Apr 24, 2013 9:34 pm
by Wishbone
I was able to do it with a jQuery hack, but it's a bit hokey.
Re: Form Builder default value for checkbox?
Posted: Wed Apr 24, 2013 9:44 pm
by Jo Morg
Wishbone wrote:Yep.. I tried y, yes, checked, true, 1
Yep I was pretty sure you had tried...

. But, as I often tend to forget the obvious, myself....

Re: Form Builder default value for checkbox?
Posted: Wed Apr 24, 2013 10:16 pm
by Wishbone
I can usually look at the code and solve most issues whether it be module or core, but I couldn't figure out this one.
I'll look at it again. If it just wasn't implemented for checkbox, I'll see how it's done with RadioButton, make a fix, then submit the code in a feature request.
Re: Form Builder default value for checkbox?
Posted: Thu Apr 25, 2013 8:49 am
by velden
Would you mind trying 't' as value:
It's a wild guess after looking at the code.
Edit: checked it on a site en seems to work.
Re: Form Builder default value for checkbox?
Posted: Thu Apr 25, 2013 2:45 pm
by Wishbone
Yes! It does work. I saw the 't' in the code, but foolishly ignored it because it always says 'value="t"' in the resulting checkbox, regardless of the "Value when checked/unchecked" in the form. Makes sense now
Thanks!
Re: [SOLVED] Form Builder default value for checkbox?
Posted: Thu Apr 25, 2013 3:14 pm
by velden
It definitely should be documenten.