When using he form API setting the default value to the value of the element in case of re-displaying the form using values stored in session or elsewhere causes the error:
Warning: html_entity_decode() expects parameter 1 to be string, array given in select_or_other_multi_array_key_exists() (line 286 of ...sites/all/modules/select_or_other/select_or_other.module).
Notice: Array to string conversion in select_or_other_element_process() (line 164 of ...sites/all/modules/select_or_other/select_or_other.module).
So you cannot use the submitted value of the element as the default value or what form does that need to be in?
array (
'select' =>
array (
'value_1' => 'value_1'',
),
'other' => 'test',
)
Comments
Comment #1
haydeniv commentedCan you post the code you are using to set the default value.
Comment #2
chrisla commentedI'm having a similar issue when using the Form API to build a "select_or_other" field.
For me, it's not related to using the default value or not. What happens is that the selected options in the $submission array for a Webform are not able to be read.
Here's what I mean:
My abbreviated code for the form itself:
The important line here is the #options being set. For me, I'm using the Form API so I can insert a variable as one of the options while allowing the users to set an option themselves.
With all options selected and no "other" element added, the $form_state['values']['submitted'] used to save to the db looks like this:
The problem seems to be that the $submission->data[4][0] is made up of more arrays. When I try to use the $submission object that is created by retrieving the data from the db, all the email addresses are just blank arrays.
Specifically, each value in $submission->data[4]['value'][0] just prints out as Array() rather than as the email address.
In the db, the row for the submission looks like the attached.
Any ideas? Is this expected?
Comment #3
haydeniv commentedDid you try setting
'#multiple' => TRUE,See: http://drupal.org/node/1158654
Comment #4
legolasboClosing because this issue has been inactive for over a year. Please reopen if this is currently an issue for you and provide steps to reproduce.