_form_set_value

Versions
4.7 – 5
_form_set_value(&$form_values, $form, $parents, $value)
6
_form_set_value(&$form_values, $form_item, $parents, $value)
7
_form_set_value(&$form_values, $element, $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

▾ 2 functions call _form_set_value()

form_set_value in includes/form.inc
Change submitted form values during the form processing cycle.
_form_set_value in includes/form.inc
Helper function for form_set_value().

Code

includes/form.inc, line 1587

<?php
function _form_set_value(&$form_values, $element, $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], $element, $parents, $value);
  }
}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.