Apache Version: 2.2.11
PHP Version: 5.2.11
Core: drupal-7.0-alpha5
Module: Webform 7.x-3.0-beta6
Error Message: Fatal error: [] operator not supported for strings in D:\wamp\www\drupal7\includes\form.inc on line 2661

Hi all,

Not sure if the problem lies with-in the core or the webform module.I created a new webform and added the following components (see screenshot).

I then browsed to the webforms url (in my case http://localhost/drupal7/content/book-now).

That is where I receive the blank page with the error message above.

I was able to resolve it by modifying the following 3 lines in the file includes/form.inc (starting on line 2657)

Change:

  if (!isset($element['#attributes']['class'])) {
    $element['#attributes']['class'] = array();
  }

To:

  //if (!isset($element['#attributes']['class'])) {
    $element['#attributes']['class'] = array();
  //}
CommentFileSizeAuthor
#3 838016.patch3.05 KBasimmonds
Screenshot of webform Components16.42 KBbaxr6

Comments

damien tournoud’s picture

Project: Drupal core » Webform
Version: 7.0-alpha5 » 7.x-3.x-dev
Component: forms system » Code

Probably webform.

quicksketch’s picture

Version: 7.x-3.x-dev » 7.x-3.0-beta6

Yep, seems we're responsible. There's probably a component setting $element['#attributes']['class'] to a string instead of an array. The approach above actually will delete all classes entirely, which isn't what we want.

There's probably a specific component responsible for this behavior, do you know which one it was that started causing this behavior?

asimmonds’s picture

StatusFileSize
new3.05 KB

Found some missing array() for class #attributes while grepping the code.

asimmonds’s picture

Status: Active » Needs review
baxr6’s picture

Patch worked a treat

ryan88’s picture

Thanks... Worked Great!

quicksketch’s picture

Status: Needs review » Fixed

Thanks asimmonds! Committed.

Status: Fixed » Closed (fixed)

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

Jonathan Baltazar’s picture

Apparently, the ['attributes']['class'] property must be set as an array in the $options array. It will throw this error if it is a string.


$options = array(
    'attributes' => array('class' => array('some-class'))
);
l($name, $url, $options);

shrimphead’s picture

Thanks #11 worked for me.