[SOLVED] Form Builder default value for checkbox?

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
Wishbone
Power Poster
Power Poster
Posts: 1368
Joined: Tue Dec 23, 2008 8:39 pm

[SOLVED] Form Builder default value for checkbox?

Post 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?
Last edited by Wishbone on Thu Apr 25, 2013 2:46 pm, edited 1 time in total.
User avatar
Jo Morg
Dev Team Member
Dev Team Member
Posts: 1978
Joined: Mon Jan 29, 2007 4:47 pm

Re: Form Builder default value for checkbox?

Post 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)?
"There are 10 types of people in this world, those who understand binary... and those who don't."
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
Wishbone
Power Poster
Power Poster
Posts: 1368
Joined: Tue Dec 23, 2008 8:39 pm

Re: Form Builder default value for checkbox?

Post by Wishbone »

Yep.. I tried y, yes, checked, true, 1
Wishbone
Power Poster
Power Poster
Posts: 1368
Joined: Tue Dec 23, 2008 8:39 pm

Re: Form Builder default value for checkbox?

Post by Wishbone »

I was able to do it with a jQuery hack, but it's a bit hokey.
User avatar
Jo Morg
Dev Team Member
Dev Team Member
Posts: 1978
Joined: Mon Jan 29, 2007 4:47 pm

Re: Form Builder default value for checkbox?

Post 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.... ;)
"There are 10 types of people in this world, those who understand binary... and those who don't."
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
Wishbone
Power Poster
Power Poster
Posts: 1368
Joined: Tue Dec 23, 2008 8:39 pm

Re: Form Builder default value for checkbox?

Post 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.
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3497
Joined: Mon Nov 28, 2011 9:29 am

Re: Form Builder default value for checkbox?

Post by velden »

Would you mind trying 't' as value:

Code: Select all

value_FIELDNAME='t'
It's a wild guess after looking at the code.

Edit: checked it on a site en seems to work.
Wishbone
Power Poster
Power Poster
Posts: 1368
Joined: Tue Dec 23, 2008 8:39 pm

Re: Form Builder default value for checkbox?

Post 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!
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3497
Joined: Mon Nov 28, 2011 9:29 am

Re: [SOLVED] Form Builder default value for checkbox?

Post by velden »

It definitely should be documenten.
Post Reply

Return to “Modules/Add-Ons”