Support

Account

Home Forums Backend Issues (wp-admin) Using radio button to hide fields in Admin

Solved

Using radio button to hide fields in Admin

  • I have a repeater in a custom ACF block, which in basic terms shows an image and some text. Here are the fields:

    $img = get_sub_field('image');
    $bordered = get_sub_field('border_radius');
    $header = get_sub_field('header');
    $text = get_sub_field('text');
    $layout = get_sub_field('layout'); // radio button with 3 options
    $highlight_background = get_sub_field('highlight_background');

    I have a ‘layout’ field that has some radio buttons to determine the layout of these fields i.e. text left / img right, text right / img left or no image / just text.

    If I select the no image radio button, I want to toggle any fields associated with the image ($img, $bordered, $highlight_background) – disappear for that particular row of the repeater to be left with just $header, $text, $layout. And then when selecting either of the other options (associated with the image), the fields reappear.

    I’ve no idea if this is feasible/possible in ACF. Please tell me otherwise!

  • Been using ACF for around 6 months and never even knew this. What an amazing feature I’ve totally been missing!

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

You must be logged in to reply to this topic.