You are here

function _field_form_state_parents in Drupal 7

Returns the location of processing information within $form_state.

2 calls to _field_form_state_parents()
field_form_get_state in modules/field/field.form.inc
Retrieves processing information about a field from $form_state.
field_form_set_state in modules/field/field.form.inc
Stores processing information about a field in $form_state.

File

modules/field/field.form.inc, line 546
Field forms management.

Code

function _field_form_state_parents($parents, $field_name, $langcode) {

  // To ensure backwards compatibility on regular entity forms for widgets that
  // still access $form_state['field'][$field_name] directly,
  // - top-level fields (empty $parents) are placed directly under
  //   $form_state['fields'][$field_name].
  // - Other fields are placed under
  //   $form_state['field']['#parents'][...$parents...]['#fields'][$field_name]
  //   to avoid clashes between field names and $parents parts.
  // @todo Remove backwards compatibility in Drupal 8, and use a unique
  // $form_state['field'][...$parents...]['#fields'][$field_name] structure.
  if (!empty($parents)) {
    $form_state_parents = array_merge(array(
      '#parents',
    ), $parents, array(
      '#fields',
    ));
  }
  else {
    $form_state_parents = array();
  }
  $form_state_parents = array_merge(array(
    'field',
  ), $form_state_parents, array(
    $field_name,
    $langcode,
  ));
  return $form_state_parents;
}