You are here

function conditional_fields_evaluate_dependencies in Conditional Fields 7.3

Evaluate a set of dependencies for a dependent field.

Parameters

$dependent: The field form element in the current language.

1 call to conditional_fields_evaluate_dependencies()
conditional_fields_dependent_validate in ./conditional_fields.module
Dependent field validation callback.

File

./conditional_fields.module, line 1002
Define dependencies between fields based on their states and values.

Code

function conditional_fields_evaluate_dependencies($dependent, $form, $form_state) {
  $dependencies = $form['#conditional_fields'][$dependent['#field_name']]['dependees'];
  $evaluated_dependees = array();
  foreach ($dependencies as $dependency_id => $dependency) {

    // Skip dependencies that can't be evaluated.
    if (!in_array($dependency['options']['condition'], array(
      'value',
      'empty',
      '!empty',
    ))) {
      continue;
    }
    $values = conditional_fields_field_form_get_values($dependency['dependee'], $form, $form_state);
    $evaluated_dependees[$dependent['#field_name']][$dependency['options']['grouping']][] = conditional_fields_evaluate_dependency('edit', $values, $dependency['options']);
  }
  return conditional_fields_evaluate_grouping($evaluated_dependees[$dependent['#field_name']]);
}