Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
renatonascalves opened this issue Jul 24, 2024 · 0 comments
Labels
bug Something isn't working javascript Requires understanding JavaScript scope:display-if ux Designing and implementing user experience improvements

Comments

@renatonascalves
Copy link

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

@renatonascalves renatonascalves added bug Something isn't working scope:display-if labels Jul 24, 2024
@kevinfodness kevinfodness added javascript Requires understanding JavaScript ux Designing and implementing user experience improvements labels Oct 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working javascript Requires understanding JavaScript scope:display-if ux Designing and implementing user experience improvements
Projects
None yet
Development

No branches or pull requests

2 participants