• Hi,

    In view_field() function from class_fields.php file, the following instructions prevent execution of um_view_field_value_checkboxn filter, which is applied later in the function:

    //hide if empty
    if ( ! in_array( $type, array( ‘block’, ‘shortcode’, ‘spacing’, ‘divider’, ‘group’ ) ) ) {
    $_field_value = $this->field_value( $key, $default, $data );

    if ( ! isset( $_field_value ) || $_field_value == ” ) {
    return;
    }
    }

    I think ‘checkbox’ should be added to the array because even if everything is unchecked, we sometimes need to proceed the result or simply display some kind of empty value, or even just the label.
    But we definitely an output, even if it’s empty.

    For instance I use um_view_field_value_checkboxn filter to display a checkbox result as real checkboxes, not as a text list.
    But I can’t do it if function returns too soon.

    I tried this and it works perfectly:

    //hide if empty
    if ( ! in_array( $type, array( ‘checkbox’, ‘block’, ‘shortcode’, ‘spacing’, ‘divider’, ‘group’ ) ) ) {
    $_field_value = $this->field_value( $key, $default, $data );

    if ( ! isset( $_field_value ) || $_field_value == ” ) {
    return;
    }
    }

    Could you fix this please?

    I think there’s no side effect because if filter is not used, then ouput is empty anyway (empty divs actually at most).

  • The topic ‘Checkbox output is empty when nothing is checked’ is closed to new replies.