Support

Account

Home Forums Bug Reports Filter field required false gives validation error

Helping

Filter field required false gives validation error

  • I am using a basic custom filter to make a field NOT required. Below is what I’m using. This worked fine up until recently. I’m on the latest stable version and may have been on 5.9 before upgrading. The field does not display a asterisk for required but when I save the page it gives the error “Validation failed. 1 field requires attention.”

    Out of an attempt to try something different, I have tried setting allow_null to true but that doesn’t make any difference.

    function make_not_required( $field ) {

    if ( true === $my_conditions ) {

    /* Do not require the field. No input should be expected if it is disabled. */
    $field[‘required’] = false;
    }

    return $field;
    }
    add_filter( ‘acf/load_field/name=my_sometimes_required_field’, ‘make_not_required’ );

  • One other thing I am doing is disabling the field with JS by just adding disabled to the select. Although, with the field NOT disabled and allow_null set to true, the issue still persists.

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

You must be logged in to reply to this topic.