Just one of many such errors to crop up in PHP 5.0.5 or higher. One solution to this one is to change the offending line,

_form_set_value($form_values[$parent], $form_item, $parents, $value);

to

$pv = $form_values[$parent];
_form_set_value($form_values[$parent], $form_item, $parents, $value);
$form_values[$parent] = $pv;

Hope this helps someone and can be fixed in core soon.

Comments

benstallings’s picture

I'm assuming you mean

$pv = $form_values[$parent];
_form_set_value($pv, $form_item, $parents, $value);
$form_values[$parent] = $pv;

Thanks for the tip!

raggax2’s picture

Status: Active » Needs review

I'm not sure this is something that needs to be addressed in core.

The whole point of this function is to recursively set form_state['values'] while keeping consistent with nested elements in the form tree. According to the comments in the code the helper function is to handle the case of:

$form_state['values']['one']['two'] = 'new value';

With the corresponding form tree having the attribute:

$form_item['#parents'] = array('one', 'two');

From what I can tell, the recursive call to _form_set_value() on line 1346 should only execute if $form_values[$parent] is an array. If $parent is a leaf in that section of the array, then the value should be set on line 1340. Your proposed fix implies that $form_values[$parent] is a literal of some sort and the function is trying to pass it as an array. My intuition tells me that this error is most likely the result of the form array not being configured correctly. It sounds like there may be a form array that looks something like this:

$form['one'] = array(
  '#type' => 'textfield',
  ...
);
$form['one']['two'] = array(
  '#type' => 'textfield',
  ...
);

In this case, form_set_value would set the $form_state['values']['one'] with a literal value and then try and pass $form_state['values']['one'] into the recursive call in 1346, resulting in the error you see, rather than setting $form_state['values']['one'] as an array to produce $form_state['values']['one']['two']'.

Can you provide an example $form array that produces this error?

Status: Needs review » Closed (outdated)

Automatically closed because Drupal 6 is no longer supported. If the issue verifiably applies to later versions, please reopen with details and update the version.