Error: Fatal error: [] operator not supported for strings in twitter_bootstrap/includes/modules/twitter_bootstrap_preprocess_table (line 233)

Temoprary solution works for me:

  function twitter_bootstrap_preprocess_table(&$variables) {
  //$variables['attributes']['class'][] = 'table';
  //$variables['attributes']['class'][] = 'table-striped';

  $variables['attributes']['class'] = array('table', 'table-striped');
}

May be this place needs some check, for example:

  function twitter_bootstrap_preprocess_table(&$variables) {
  if(!isset($variables['attributes']['class'])) {
    $variables['attributes']['class'] = array('table', 'table-striped');
  }
  else {
    $variables['attributes']['class'][] = 'table';
    $variables['attributes']['class'][] = 'table-striped';
  }
}

Comments

avr’s picture

Here's a little different check (I think I saw this somewhere else) that ensures any existing classes are an array and then adds Bootstrap classes:

function twitter_bootstrap_preprocess_table(&$variables) {
  if (isset($variables['attributes']['class']) && is_string($variables['attributes']['class'])) {
   // Convert classes to an array.
   $variables['attributes']['class'] = explode(' ', $variables['attributes']['class']);
  }

  $variables['attributes']['class'][] = 'table';
  $variables['attributes']['class'][] = 'table-striped';
}
andregriffin’s picture

Project: Twitter's Bootstrap » Bootstrap Framework
Version: 7.x-2.0-beta1 » 7.x-2.x-dev
andregriffin’s picture

Project: Bootstrap Framework » Twitter's Bootstrap
natted’s picture

Project: Twitter's Bootstrap » Bootstrap
frankbaele’s picture

Status: Active » Fixed

commited #1

Status: Fixed » Closed (fixed)

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

Anonymous’s picture

Issue summary: View changes

added path to file