All pastes #608549 Raw Edit

Unnamed

public text v1 · immutable
·published 2007-07-08 11:36 UTC
rendered paste body
<?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;
}

$fv = array(
  'text' => '',
  'test_of_vocabulary' => 21,
);
$f['#parents'] = array('test_of_vocabulary', 'test_of_vocabulary-level-0');
$p = array('test_of_vocabulary', 'test_of_vocabulary-level-0');
$v = 5;
_form_set_value($fv, $f, $p, $v);