Support

Account

Home Forums General Issues Display unmarked checkbox

Helping

Display unmarked checkbox

  • Good afternoon!

    I’m trying to use the CheckBox option to select options that an apartment has , but need to display the oções that also are not marked . How Do I ?

    Ex .

    If the apartment has 1 TV, TV will show and a signal OK … if you have no TV , I view TV and an X

  • Hi @crishenrique1986 ,

    In order to show all the checkbox options including the not selected, the following code should help you out.

    $values = get_field('checkbox_field_name');
    $field = get_field_object('checkbox_field_name');
    $choices = $field['choices'];
    foreach ($choices as $value => $label) {
        echo $label,': ';
        if (in_array($value, $values)) {
            echo 'marked';
        }
        echo '<br />';
    }

    I hope this helps.

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

You must be logged in to reply to this topic.