hook_field_group_build_pre_render_alter multiple conditions on #states not working.

Created on 1 November 2017, over 6 years ago
Updated 1 June 2024, about 1 month ago

I am building a form using field groups and one section is set up like so:


hook_field_group_build_pre_render_alter (&$element) {

// An array of all accepted majors
$majors = majors();


// Groups will show only if the user selects 'ohio' and certain majors from $major array.
$element['group_college']['group_majors']['#states'] = array (
	'visible' => array (
		':input[name="field_majors[und]"]' => array ( $majors, ),
		':input[name="field_campus[und]"]' => array (
			array ('value' => t('ohio')),
		),
	),
	'required' => array (
		':input[name="field_majors[und]"]' => array ( $majors, ),
		':input[name="field_campus[und]"]' => array (
			array ('value' => t('ohio')),
		),
	),
	'enabled' => array (
		':input[name="field_majors[und]"]' => array ( $majors, ),
		':input[name="field_campus[und]"]' => array (
			array ('value' => t('ohio')),
		),
	),
);
}

When the user selects certain values from a dropdown selection and the radio value is 'ohio' they will see a collection of fields to fill out. This is successful the first time. However, when if the user were to re-select another value from $major, the collection of fields will not reload/disappear.

This will work only if I use one :input, but these fields are contingent on both conditions being true.

Any suggestions?

πŸ› Bug report
Status

Closed: won't fix

Version

1.0

Component

Miscellaneous

Created by

πŸ‡ΊπŸ‡ΈUnited States Walmart_Shoes

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.69.0 2024