Quick question about Dynamic field default values and checkboxes

By: Raul Diego | Asked: 10/25/2024
ForumsCategory: General questionsQuick question about Dynamic field default values and checkboxes
Raul Diego asked 3 days ago
With a normal checkbox or radio button, it's easy to have the field checked or marked by default when a form is loaded. For some reason, this is not the case when the checkbox or radio button are populated with dynamic values. Is there any way to achieve this? I have a checkbox populated dynamically with only one value, which I need to have checked by default when the form loads. Can anybody help?
1 Answers
Rob LeVineRob LeVine answered 3 days ago
Did you read this? I've never done it, so I can't say for sure it's the answer to your question.
Raul Diego replied 3 days ago

Thanks Rob. I'm not having issues with default values, rather having a checkbox field checked by default.

When checkbox options are inputed directly in the form builder it's a simple matter of checking the option I want checked by default in the form, but when the options are populated dynamically it doesn't seem to allow that. So I'm trying to figure out how to have a dynamically populated checkbox option checked by default.

Victor Font replied 3 days ago

Having a checkbox field checked by default IS a default value.

Raul Diego replied 2 days ago

Thanks, Victor. I guess that since my checkbox field already has a default value populating the option (it only has one), then I have to add the default "checked" value programmatically?

Victor Font replied 2 days ago

Raul, I think there's some confusion over the definition of default value. You are not populating your dynamic field with a default value. It is not a default until it is checked before it is displayed.

Default value means a pre-selected value for a field. What you are displaying is an unselected option. Read the documentation in the KnowledgeBase article I referenced or follow the directions that Rob suggested to you.

If you don't want to use the hook that Formidable provides that solves your problem, then do in jQuery when the form loads in the browser. Those are your alternatives.

Raul Diego replied 2 days ago

Right, I am not a programmer so my references are bound to be incorrect. In any case, I get that the "value" is in this case like the state of the checkbox, but at the same time, while the option is being populated dynamically, I am using the default value box in the form builder to pre-select it. However, it does not show up as selected on the frontend as it normally would with a regular (non-dynamic) checkbox.

I didn't see anything that would solve my problem in your suggested material, but I'll go through it again.

Making the Best WordPress Plugin even better - Together

Take on bigger projects with confidence knowing you have access to an entire community of Formidable Experts and Professionals who have your back when the going gets tough. You got this!
Join the community
crossarrow-right