Fatal error: [] operator not supported for strings in /usr/local/www/drupal/sites/all/modules/webform/components/select.inc on line 172

Drupal 5.1
Latest release of Webform.

No issue if I'm not using selects.

Comments

phillipadsmith’s picture

And, actually, it's only "multiple" selects (and only with more than one submission) -- the select list is working fine.

neruocomp’s picture

Ran into this problem also, could not view results, and fixed it by changing the following. I'm not a developer myself, so not sure if this is valid, but it works for me.

function _webform_submission_display_select($data, $component) {
  $form_item = _webform_render_select($component);
  if ($component['extra']['multiple'] == 'Y') {
    // Set the value as an array
    foreach ((array)$data['value'] as $key => $value) {
      if (array_key_exists(_webform_safe_name($value), $form_item['#options'])) {
        $form_item['#default_value'][] = _webform_safe_name($value);
      }
      else {
        $form_item['#default_value'][] = $value;
      }
    }
  }
...
function _webform_submission_display_select($data, $component) {
  $form_item = _webform_render_select($component);
  if ($component['extra']['multiple'] == 'Y') {
    // Set the value as an array
    foreach ((array)$data['value'] as $key => $value) {
      if (array_key_exists(_webform_safe_name($value), $form_item['#options'])) {
        $form_item['#default_value'] = _webform_safe_name($value);
      }
      else {
        $form_item['#default_value'] = $value;
      }
    }
  }
...
defagordi’s picture

I have the same Problem, i change the line 172 and 175 of the select.inc to:

 if ($component['extra']['multiple'] == 'Y') {
    // Set the value as an array
    foreach ((array)$data['value'] as $key => $value) {
      if (array_key_exists(_webform_safe_name($value), $form_item['#options'])) {
        $form_item['#default_value'][$key] = _webform_safe_name($value);
      }
      else {
        $form_item['#default_value'][$key]= $value;
      }
    }
  }

It's working only if we dont have a default value for a checkbos option

bdornbush’s picture

I ran into this bug in 5.x-1.4 and upgraded to 5.x-1.7. The bug is still there, except it is now at line 180.

janv’s picture

Version: 5.x-1.4 » 5.x-1.7

same prob here as bdornbush

palmstrom’s picture

Version: 5.x-1.7 » 5.x-1.x-dev
Status: Active » Needs review
StatusFileSize
new569 bytes

Here is patch against 5.x-1.7. It's solving bug bit differently, so It should be ok with default values.

quicksketch’s picture

Thanks for the patch palmstrom, but it seems that it will cause the incorrect values to be selected in the list if the <option value=""> is not the same as the label displayed.

I haven't yet been able to reproduce this in the latest dev, can you provide more information about what is necessary to cause the problem?
- Create webform
- Add a select list
- Multiple value
- List box
- Not required
- Options:
One
Option 2
Option Three
- Save webform
- Add submission
- View submission result

summit’s picture

Subscribing! May be related to: http://drupal.org/node/162948#comment-681797 ?

Greetings,
Martijn

Bodo Maass’s picture

I just got the same problem with 5.x-1.x-dev.
Steps to reproduce:
Create webform.
Add select list.
Multiple value.
Mandatory.
Enter single option of the form: label|description
set the default value to "label".

Submit form.
Edit results of this submission: this will cause "Fatal error: [] operator not supported for strings in select.inc on line 180

quicksketch’s picture

Status: Needs review » Fixed
StatusFileSize
new787 bytes

Thank you Bodo Maass! That's exactly what I needed. I reproduced on both 1.x and 2.x and fixed the problem in both places. You can either upgrade to the latest 1.x to solve the problem or apply this patch to get it working in 1.8. Thanks!

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.