This line of code:

  $variables['questions_list'] = theme('item_list', array('items' => $questions, 'title' => NULL, 'type' => $list_style, 'attributes' => array("class" => "faq-ul-questions-top")));

Needs to be changed to this:

  $variables['questions_list'] = theme('item_list', array('items' => $questions, 'title' => NULL, 'type' => $list_style, 'attributes' => array("class" => array("faq-ul-questions-top"))));

In D7, class attributes always need to be passed as an array, not a string. By passing a string, it causes errors when trying to render the attributes, as classes are expected to be an array, not a string. In my case, I've overridden theme_item_list(), and I'm adding another class to the item list as follows:

  $attributes['class'][] = 'item-list';

However, since the FAQ module has pass the class as a string, trying to use the above code results in the error that I've provided in the title.

Comments

jaypan’s picture

Also, as a side note, it would be nice if you changed the double quotes to single quotes, to be consistent with the rest of the line of code.

jaypan’s picture

Bump

  • sudev.pradhan committed d8ce578 on 7.x-2.x
    Issue #1997034 by jaypan: Fix for issue - Fatal error: [] operator not...
sudev.pradhan’s picture

Issue summary: View changes
Status: Active » Closed (fixed)

Added in the fixes mentioned by jaypan. Closing this as issue is now resolved.