You are here

function _form_set_value in Drupal 4

Same name and namespace in other branches
  1. 5 includes/form.inc \_form_set_value()
  2. 6 includes/form.inc \_form_set_value()

Helper function for form_set_value().

We iterate of $parents and create nested arrays for them in $form_values if needed. Then we insert the value in the right array.

Related topics

1 call to _form_set_value()
form_set_value in includes/form.inc
Use this function to make changes to form values in the form validate phase, so they will be available in the submit phase in $form_values.

File

includes/form.inc, line 498

Code

function _form_set_value(&$form_values, $form, $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, $parents, $value);
  }
  return $form;
}