I'm trying to change the value of a form within a custom Commerce Pane during validation but I get the following error:
Recoverable fatal error: Argument 2 passed to drupal_array_set_nested_value() must be an array, string given, called in /var/www/vhosts/innovista.org/httpdocs/includes/form.inc on line 2514 and defined in drupal_array_set_nested_value() (line 6440 of /var/www/vhosts/innovista.org/httpdocs/includes/common.inc).
As far as I see my code is an array.
form_set_value($form_state['values'][$checkout_pane['pane_id']]['donation_amount'], array('und' => array(0 => array('value' => '999'))), $form_state);
I've been using $checkout_pane['pane_id'] . '][donation_amount'
with form_set_error()
, and it works fine. I can't understand why argument 2 is not working.
I have tried setting #parents as this question suggests: Using form_set_value() in Drupal 7
In the following way:
$form_state['values'][$checkout_pane['pane_id']]['donation_amount']['#parents'] = array( 'values',$checkout_pane['pane_id'], 'donation_amount');
But this produces an extra error:
Notice: Array to string conversion in donation_checkout_pane_pane_checkout_form_validate() (line 186 of /var/www/vhosts/innovista.org/httpdocs/sites/all/modules/donation_checkout_pane/donation_checkout_pane.module).
Do you have any idea?