Support

Account

Home Forums General Issues Clear value of conditional field when radio not selected

Helping

Clear value of conditional field when radio not selected

  • I have a field with two options (radio).
    Option 1 selected, show conditional field 1
    Option 2 selected, show conditional field 2

    In my template I am now testing if field 1 is empty to determine which value to echo out:

    
    <?php 
    if(get_field('field_1')){
      echo the_field('field_1');
    } else {
      echo the_field('field_2');
    ?>
    

    Problem is that i can enter a value into both Field 1 and 2. The conditional really only toggles its visibility.

    Is there a way to clear the field if the ACF conditions are not met?
    Alternatively, can someone suggest a more elegant if statement to handle this situation?

  • Nevermind, I can (and should) test against the radio value instead.

    Is there no way to delete forum posts?

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

The topic ‘Clear value of conditional field when radio not selected’ is closed to new replies.