Support

Account

Home Forums Add-ons Flexible Content Field Populate Flexible Content Field automatically based on Radio Group choices.

Solved

Populate Flexible Content Field automatically based on Radio Group choices.

  • Hi guys, I am in a struggle because I need to use the flexible content for something huge, I will end up with like 300+ fields, or maybe and probably more that I need to hide conditionally based on the choosen category, at that point I am using the ACF default Conditional Logic, it is working fine although it is kinda frustrating because it pops all fields and hide them with display:none, after few seconds of loading the page, the problem actually is that I don’t have even 1/10 of the fields that I will end up with and there are already some delays in the posting and showing the fields etc..

    I tought that using the flexible content addon would be a better solution but I can’t seem to find anything about the following case :

    I have radio button group like that :
    “Auto”, “Houses”, “Pets” and few more..

    I need to show 10 fields if “Auto” is selected from the radio group, and hide them and show new ones if “Houses” is selected from the radio group.

    I saw that I can limit the number of rows that the flexible content can have, but I am thinking when I use it with conditional logic like : if “Auto” is selected show me “Flexible content 1” and if “Houses” are selected show me “Flexible content 2” and since they are 2 different fields, can’t I skip the add new button at whole, and populate the flexible content fields programatically (automatically) based on the radio group choices.

    I am really in need so any help would be really appreciated thank you, for your time to read this. 🙂

  • Hi @nikya

    I’m afraid flexible content field is designed to allow you choose the layout you want. If you only use one layout in one flexible content field, I suggest you use the repeater field instead. You can also set it to show a minimum of ten fields in the settings. To learn more about repeater field, please take a look at this page: https://www.advancedcustomfields.com/resources/repeater/.

    I hope this makes sense 🙂

  • James thank you in fact I noticed this about the repeated field, yesterday and this is the approach that I am about to take, I have one more question doe.

    Is the Repeater Field faster, and more reliable than the usual way that we use conditional logic for the fields.

    Thanks again for your answer.

  • Hi @nikya

    It depends on how you use it. The conditional logic is used if you want to hide/show certain fields if a certain option is selected. On the other hand, the repeater field is used if you want to add multiple groups of data with the same structure. So basically they are different, so I can’t really answer that question.

    I hope this makes sense 🙂

  • Well since I need to conditionally hide a lot of fields, based on a radio button choice I guess I’ll end up with more than 300 fields, I will go for the repeater approach, because it looks more reliable to me, also there isn’t any fields which pop on load, and then hide.

    It seems like the page load time sagnifically reduced, so thanks for your help really. 🙂

Viewing 5 posts - 1 through 5 (of 5 total)

The topic ‘Populate Flexible Content Field automatically based on Radio Group choices.’ is closed to new replies.