--- conditional_fields-fixed_multiple_field_collection_fields-1464950-109-no-whitespaces-do-not-test.patch 2013-12-11 16:36:27.000000000 +0100 +++ conditional_fields-fixed_multiple_field_collection_fields-1464950-114-no-whitespaces-do-not-test.patch 2013-12-17 16:45:52.391665809 +0100 @@ -1,5 +1,5 @@ diff --git a/conditional_fields.module b/conditional_fields.module -index 27ea7ee..37f7b2f 100644 +index 27ea7ee..75146e7 100644 --- a/conditional_fields.module +++ b/conditional_fields.module @@ -259,11 +259,13 @@ function conditional_fields_element_after_build($element, &$form_state) { @@ -67,77 +67,56 @@ - foreach ($form['#conditional_fields'] as $dependent => $dependent_info) { + foreach ($form['#conditional_fields'] as $parent_dependent_key => $parent_dependent_info) { + foreach ($parent_dependent_info as $dependent => $dependent_info) { - $states = array(); + $states = array(); - if (empty($dependent_info['dependees'])) { - continue; - } + if (empty($dependent_info['dependees'])) { + continue; + } - - $dependent_location = array_merge($dependent_info['field_parents'], array($dependent)); - $dependent_form_field = drupal_array_get_nested_value($form, $dependent_location); + $dependent_location = array_merge($dependent_info['field_parents'], array($dependent)); + $dependent_form_field = drupal_array_get_nested_value($form, $dependent_location); -@@ -442,11 +444,11 @@ function conditional_fields_form_after_build($form, &$form_state) { - foreach ($dependent_info['dependees'] as $dependency) { - $dependee = $dependency['dependee']; +@@ -442,7 +444,7 @@ function conditional_fields_form_after_build($form, &$form_state) { + foreach ($dependent_info['dependees'] as $dependency) { + $dependee = $dependency['dependee']; - if (empty($form['#conditional_fields'][$dependee])) { -+ if (empty($form['#conditional_fields'][$parent_dependent_key][$dependee])) { - continue; - } - -- $dependee_info = $form['#conditional_fields'][$dependee]; -+ $dependee_info = $form['#conditional_fields'][$parent_dependent_key][$dependee]; - $dependee_form_field = drupal_array_get_nested_value($form, $dependee_info['parents']); - $options = $dependency['options']; ++ if (empty($form['#conditional_fields'][$parent_dependent_key][$dependee])) { + continue; + } @@ -477,7 +479,6 @@ function conditional_fields_form_after_build($form, &$form_state) { - unset($behaviors[CONDITIONAL_FIELDS_FIELD_EDIT_HIDE_ORPHAN]); - continue; - } -- - unset($behaviors[CONDITIONAL_FIELDS_FIELD_EDIT_HIDE_UNTRIGGERED_ORPHAN]); unset($behaviors[CONDITIONAL_FIELDS_FIELD_EDIT_HIDE_ORPHAN]); + continue; + } +- + unset($behaviors[CONDITIONAL_FIELDS_FIELD_EDIT_HIDE_UNTRIGGERED_ORPHAN]); + unset($behaviors[CONDITIONAL_FIELDS_FIELD_EDIT_HIDE_ORPHAN]); -@@ -527,6 +528,7 @@ function conditional_fields_form_after_build($form, &$form_state) { - $state = array($options['state'] => array($options['selector'] => $values)); - $dependee_form_state = isset($dependee_form_field['#field_parents'], $dependee_form_field['#field_name'], $dependee_form_field['#language']) ? field_form_get_state($dependee_form_field['#field_parents'], $dependee_form_field['#field_name'], $dependee_form_field['#language'], $form_state) : NULL; - -+ - // Execute special handler for fields that need further processing. - // The handler has no return value. Modify the $state parameter by - // reference if needed. -@@ -535,10 +537,10 @@ function conditional_fields_form_after_build($form, &$form_state) { - $handler($dependee_form_field, $dependee_form_state, $options, $state); - } +@@ -535,10 +536,10 @@ function conditional_fields_form_after_build($form, &$form_state) { + $handler($dependee_form_field, $dependee_form_state, $options, $state); } + } + } // Add validation callback to element. _conditional_fields_element_add_property($dependent_form_field, '#element_validate', 'conditional_fields_dependent_validate', 'append'); - } - // Add the $state into the correct logic group in $states. - foreach ($state as $key => $constraints) { -@@ -549,6 +551,7 @@ function conditional_fields_form_after_build($form, &$form_state) { - $states[$key][$options['grouping']] = array_merge($states[$key][$options['grouping']], $constraints); - } + // Add the $state into the correct logic group in $states. + foreach ($state as $key => $constraints) { +@@ -549,6 +550,7 @@ function conditional_fields_form_after_build($form, &$form_state) { + $states[$key][$options['grouping']] = array_merge($states[$key][$options['grouping']], $constraints); } -+ } + } ++ } - // Build effect settings for effects with options. - // TODO: add dependee key to allow different effects on the same selector. -@@ -565,24 +568,12 @@ function conditional_fields_form_after_build($form, &$form_state) { - 'options' => $options['effect_options'], - ); - } -- - // Apply reset dependent to default if untriggered behavior. - if (in_array(CONDITIONAL_FIELDS_FIELD_EDIT_RESET_UNTRIGGERED, $behaviors)) { - // Add property to element so conditional_fields_dependent_validate() can - // pick it up. - $dependent_form_field['#conditional_fields_reset_if_untriggered'] = TRUE; -- unset($behaviors[CONDITIONAL_FIELDS_FIELD_EDIT_RESET_UNTRIGGERED]); -- } + // Build effect settings for effects with options. + // TODO: add dependee key to allow different effects on the same selector. +@@ -573,16 +575,6 @@ function conditional_fields_form_after_build($form, &$form_state) { + $dependent_form_field['#conditional_fields_reset_if_untriggered'] = TRUE; + unset($behaviors[CONDITIONAL_FIELDS_FIELD_EDIT_RESET_UNTRIGGERED]); + } - } - - // Execute custom behaviors callbacks. @@ -148,19 +127,27 @@ - } - - unset($behaviors); -+ unset($behaviors[CONDITIONAL_FIELDS_FIELD_EDIT_RESET_UNTRIGGERED]); } - if (empty($states)) { - continue; -@@ -626,6 +617,7 @@ function conditional_fields_form_after_build($form, &$form_state) { + if (empty($states)) { + continue; +@@ -606,7 +598,7 @@ function conditional_fields_form_after_build($form, &$form_state) { + foreach ($states[$state_key]['OR'] as $constraint_key => $constraint_value) { + $or[] = array($constraint_key => $constraint_value); + } +- // '1' as a string so that we get an object (which means logic groups ++ // '1' as a string so that we get an object (which means logic groups + // are ANDed together). + $states_new[$state_key]['1'] = $or; + } +@@ -626,6 +618,7 @@ function conditional_fields_form_after_build($form, &$form_state) { - $has_states = TRUE; - } + $has_states = TRUE; + } + } if (empty($has_states)) { return $form; -@@ -994,13 +986,14 @@ function conditional_fields_evaluate_grouping($groups) { +@@ -994,13 +987,14 @@ function conditional_fields_evaluate_grouping($groups) { * The field form element in the current language. */ function conditional_fields_evaluate_dependencies($dependent, $form, $form_state) { @@ -177,12 +164,11 @@ // We have the parents of the field, but depending on the entity type and // the widget type, they may include additional elements that are actually -@@ -1982,3 +1975,20 @@ function conditional_fields_features_api() { +@@ -1982,3 +1976,19 @@ function conditional_fields_features_api() { ), ); } + -+ +/** + * Flatten a one-dimensional array. + */