function conditional_fields_field_form_get_values in Conditional Fields 7.3
Extracts field values from a submitted form.
1 call to conditional_fields_field_form_get_values()
- conditional_fields_evaluate_dependencies in ./
conditional_fields.module - Evaluate a set of dependencies for a dependent field.
File
- ./
conditional_fields.module, line 1023 - Define dependencies between fields based on their states and values.
Code
function conditional_fields_field_form_get_values($field_name, $form, $form_state) {
$field_parents = $form['#conditional_fields'][$field_name]['parents'];
// 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
// part of the value. So we find the depth of the field inside the form
// structure and use the parents only up to that depth.
$field_parents_keys = array_flip($field_parents);
$field_parent = drupal_array_get_nested_value($form, array_slice($field_parents, 0, $field_parents_keys[$field_name]));
$values = conditional_fields_field_get_values($field_parent[$field_name], $form_state);
// Remove the language key.
if (isset($field_parent[$field_name]['#language'], $values[$field_parent[$field_name]['#language']])) {
$values = $values[$field_parent[$field_name]['#language']];
}
return $values;
}