carbon-fields
carbon-fields copied to clipboard
Required Fields inside Containers with Conditions to Display For Other Templates Render the Update Button Disabled for Current Template
Version
- Carbon Fields: 3.6
- WordPress: 6.2.2
- PHP: 7.4
Expected Behavior
Page editor Update button should not be disabled if required fields inside containers intended for other templates are left blank.
Actual Behavior
Page editor Update button is disabled, due to Carbon Fields incorrectly interpreting there are required fields left blank for the current template, when those required fields are actually for another template and not visible on the page.
Container definition
Container::make( 'post_meta', __( 'Contact Form Template Settings', 'crb' ) )
->where( 'post_type', '=', 'page' )
->where( 'post_template', '=', 'templates/some-other-template.php' )
->add_fields( array(
Field::make( 'text', 'some_text_field', __( 'Some Text Field', 'crb' ) )
->set_required(true)
) );
Steps to Reproduce the Problem
- Edit a page that is of a template other than one named
templates/some-other-template.php - Ensure any required fields for the current template are fulfilled
- Observe the Update button remains disabled and unclickable
Comments
Recently updated from 3.1 to 3.6, and this was not an issue in 3.1.
Also faced this problem.
Had to remove everywhere ->set_required( true ) 😟
Not fixed yet?