carbon-fields icon indicating copy to clipboard operation
carbon-fields copied to clipboard

Required Fields inside Containers with Conditions to Display For Other Templates Render the Update Button Disabled for Current Template

Open mikeyandaya-rhythm opened this issue 2 years ago • 4 comments

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

  1. Edit a page that is of a template other than one named templates/some-other-template.php
  2. Ensure any required fields for the current template are fulfilled
  3. 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.

mikeyandaya-rhythm avatar Jul 02 '23 03:07 mikeyandaya-rhythm

Also faced this problem. Had to remove everywhere ->set_required( true ) 😟

imhvost avatar Jul 11 '23 14:07 imhvost

Not fixed yet?

vitalbielik avatar Sep 28 '23 11:09 vitalbielik