_form_set_value

Versions
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_values if needed. Then we insert the value into the right array.

Related topics

▾ 2 functions call _form_set_value()

form_set_value in drupal/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 drupal/includes/form.inc
Helper function for form_set_value().

Code

drupal/includes/form.inc, line 852

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

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • Web page addresses and e-mail addresses turn into links automatically.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters (without spaces) shown in the image.