_form_set_value

  1. drupal
    1. 4.7
    2. 5
    3. 6 form.inc
Versions
4.7 – 5 _form_set_value(&$form_values, $form, $parents, $value)
6 _form_set_value(&$form_values, $form_item, $parents, $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

▾ 2 functions call _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.
_form_set_value in includes/form.inc
Helper function for form_set_value().

Code

includes/form.inc, line 499

<?php
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;
}
?>