Home › Forums › Add-ons › Repeater Field › Radio Button and Repeater Subfields › Reply To: Radio Button and Repeater Subfields
Yes, I think there is. Since the additional fields are based on the radio button field, get the radio button field and test it’s value to determine which of the other fields to get and display.
if ($radio == 'choice_1') {
// display fields
} elseif ($radio == 'choice_2') {
// display fields
} elseif etc...
or better yet
switch ($radio_field) {
case 'choice 1':
//display fields
break;
}
If fields can be displayed for multiple choices you may want to put them into functions so they can be called that way rather than duplicating the code to display them over and over again.
You’ll also find that sooner or later you’ll be showing the wrong fields. For example, if they change the choice later that hides one of the fields the hidden field will still have a value, so you’ll need to check the radio field for that reason any way.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.