Support

Account

Home Forums Front-end Issues Hidden-by-conditional-logic get posted and create problems. Reply To: Hidden-by-conditional-logic get posted and create problems.

  • If the field never had a value, then in will not have a value saved, but if the field has a value and you change the condition and the field is hidden then whatever value was in that field before will remain in the field.

    An example

    Let say we have something like this
    – Radio Field
    —- choice 1
    —- chioce 2
    – Text field 1, appears for choice 1
    – text field 2, appears for choice 2

    Select choice 1 and enter a value in text field 1 and save the post.

    Edit the post and select choice 2 and enter a value into text field 2 then save the post. The value previously entered into text field 1 will still be in the database.

    This is working as expected in ACF and it requires that you create if conditions when showing the values on the front end. Conditional logic on the back end is strictly for showing and hiding fields on the back end to build a logical user interface and does not control the display of the front end. When a field is hidden by conditional logic that field is not submitted, since it is not submitted, then it is not updated, or removed.

    
    $choice = get_field('radio_field');
    if ($choice == 'choice 1') {
      // show text field 1
      the_field('text_field_1');
    } else {
      // show text field 2
      the_field('text_field_2);
    }
    

    If you want values to be removed when a post is updated then you will need to create an acf/save_post filter that checks the radio field and deletes the value that you no longer want.