Skip to content

display_if condition doesn't hide active fields that have their own custom display_if condition #874

@renatonascalves

Description

@renatonascalves

Description of the bug

As titled.

Steps To Reproduce

function add_custom_meta_boxes() {
	$custom_meta_group = new Fieldmanager_Group(
		array(
			'name'           => 'custom_group',
			'children'       => array(
				'meta'   => new Fieldmanager_Checkbox(
					[
						'save_empty'    => false,
						'checked_value' => 'meta',
						'label'         => 'Checkbox',
					]
				),
				'subject_prefix'        => new Fieldmanager_Select( 
					[
						'name'          => 'subject_prefix',
						'label'         => 'Subject prefix',
						'options'       => [
							'none'   => 'None',
							'custom' => 'Custom',
						],
						'default_value' => 'none',
						'display_if'  => [ // <--- this field requires the `meta` field to be active.
							'src'   => 'meta',
							'value' => 'meta',
						],
					]
				),
				'subject_prefix_custom' => new Fieldmanager_Textfield(
					[
						'label'       => 'Custom subject prefix',
						'display_if'  => [ // <--- this field requires the `subject_prefix` field to be active and indirectly, the `meta` field too.
							'src'   => 'subject_prefix',
							'value' => 'custom',
						],
					]
				),
			),
		)
	);

	// Add the group to a post type
	$custom_meta_group->add_meta_box( 'Custom Meta', 'your-post-type', 'normal', 'high' );
}
add_action( 'admin_init', 'add_custom_meta_boxes' );
CleanShot.2024-07-24.at.00.12.42-converted.mp4

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingjavascriptRequires understanding JavaScriptscope:display-ifuxDesigning and implementing user experience improvements

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions