4.7.x form.inc _form_set_value(&$form_values, $form, $parents, $value)
5.x form.inc _form_set_value(&$form_values, $form, $parents, $value)
6.x form.inc _form_set_value(&$form_values, $form_item, $parents, $value)

Helper function for form_set_value().

We iterate over $parents and create nested arrays for them in $form_state['values'] if needed. Then we insert the value into the right array.

Related topics

1 call to _form_set_value()
form_set_value in includes/form.inc
Change submitted form values during the form processing cycle.

File

includes/form.inc, line 1426

Code

function _form_set_value(&$form_values, $form_item, $parents, $value) {
  $parent = array_shift($parents);
  if (empty($parents)) {
    $form_values[$parent] = $value;
  }
  else {
    if (!isset($form_values[$parent])) {
      $form_values[$parent] = array();
    }
    _form_set_value($form_values[$parent], $form_item, $parents, $value);
  }
}