3

Although i have found the fix of this problem, but i thought of sharing with others.

Problem is if you mention $rows & theme_table like following:

$row[] = array('data' => drupal_render($form[$key]['alt_name']), 'class' => 'alt-ing-name-td');

$output = theme_table(array('header' => $header, 'rows' => $rows,'attributes' => array('id' => 'recipe-id')));

then you will get following error:

Fatal error: [] operator not supported for strings in theme.inc
1
  • thanks, this saved me a lot of time porting a drupal 6 module to drupal 7 – Will Tate Aug 1 '13 at 19:52
3

To fix this problem you need to mention class & id values in array. PFB, the corrections:

$row[] = array('data' => drupal_render($form[$key]['alt_name']), 'class' => array('alt-ing-name-td'));

$output = theme_table(array('header' => $header, 'rows' => $rows,'attributes' => array('id' => array('recipe-id'))));

Hope this will help.

2
  • 1
    Just a note: this isn't exclusive to theme_table(), (nearly?) all theme functions that use HTML class attributes expect an array rather than a string in Drupal 7 – Clive May 31 '13 at 18:12
  • +1, You are right. During migration from 6 to 7, i have noticed this. – Sumoanand May 31 '13 at 18:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.