You are here

function conditional_fields_states_handler_text in Conditional Fields 7.3

States handler for text fields.

1 call to conditional_fields_states_handler_text()
conditional_fields_states_handler_textarea in ./conditional_fields.module
States handler for text areas.

File

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

Code

function conditional_fields_states_handler_text($field, $field_info, $options, &$state) {

  // Text fields values are keyed by cardinality, so we have to flatten them.
  // TODO: support multiple values.
  if ($options['values_set'] == CONDITIONAL_FIELDS_DEPENDENCY_VALUES_WIDGET) {

    // Cast as array to handle the exception of autocomplete text fields.
    $value = (array) $state[$options['state']][$options['selector']]['value'][0];
    $state[$options['state']][$options['selector']]['value'] = array_shift($value);
  }
}