Hi there,
Is there a way to set the state of a generic checkboxes field option to checked?
Something like
{"value":"1", "label":"Option 1", "checked":"1"}
?
Thanks - Mark
Hi, the checked item is not defined in your list of options, instead it is defined by the "default" attribute in the generic field:
[cred_generic_field field='mycheckboxes' type='checkboxes' class='' urlparam='']
{
"required":0,
"validate_format":0,
"default":["123"],
"options":[
{"value":"123","label":"abc"},
{"value":"234","label":"def"}
]
}
[/cred_generic_field]
In this case, the "abc" checkbox will be automatically checked. If you use the GUI to set up a custom field, you can select the default checked value in the options area.
Hi Thanks Christian,
Wow that would have saved me a lot of time. I actually solved the problem myself using an AJAX call and post meta I created with info about the fields rendered on the original form and their state at save time.
I would love to be able to find documentation for these sort of things. For example, can you point me to where the attributes for the CRED generic field are explained? I suppose the default attribute is really the only one that I needed help with.
Thanks again,
Mark
Hi, you can find documentation about CRED shortcodes here:
https://toolset.com/documentation/user-guides/cred-shortcodes/
A good general launchpad for reference material and documentation can be found here, including links to shortcode details and programmer references:
https://toolset.com/documentation/
Hi Christian,
Thanks for taking the time to reply. I have to say that I did look at the two links you posted above before submitting my support request. I couldn't find anything more about cred generic checkboxes fields than what's here:
https://toolset.com/documentation/user-guides/cred-shortcodes/#cred_generic_field
The example there doesn't say a word about any of the parameters that can be set.
There are many support requests from people not understanding that they have to save the generic field data to the DB themselves, there is some confusion about checkbox and checkboxes fields, and there were a flurry of support requests about a bug where boxes were all checked by default around mid 2016, however I didn't find anything about how to render a checkbox checked.
I really do appreciate the support and I may have overlooked where in the documentation this is spelled out. If so please put me out of my misery.
Thanks again,
Mark.