Hi all,
when I use theme_table() in D7 got error below

[Wed Feb 16 23:45:45 2011] [error] [client 192.1.8.133]
PHP Fatal error: Unsupported operand types in /......../includes/form.inc on line 993

Here is my code

function theme_print_form(){
	drupal_set_message('test table');

	$variable = array();
	$variable['header'] = array(
		array('data' => t('Coupon'), 'field' => 'coupon', 'sort' => 'asc'),
		array('data' => t('Type of Discount')),
		array('data' => t('Created'), 'field' => 'created'),
		array('data' => t('Expire'), 'field' => 'expire'),
		array('data' => t('Status'), 'field' => 'used'),
		array('data' => t('Used by')),
	);
  	$variable['rows'] = array(
		array('a','b','c','d','e','f'),
		array('a','b','c','d','e','f'),
	);
	$variable['attributes'] = array();

	return theme_table($variable);
}

What's wrong in my code?

Any help is appreciated.

Keith

Comments

kuldip zala’s picture

MPeli’s picture

Hi,

I am facing the same problem. Could anybody tell me what is wrong with the code above?

	$header = array('A');
	$rows = array(
      array(
        'data' =>'Cell 1'
      ),
      array(
        'data' =>'Cell 1'
      ),
    );
  $output .= theme('table', array('header' => $header, 'rows' => $rows));

Both codes give me the same errors.
Fatal error: Unsupported operand types in C:\xampp\htdocs\drupal7\includes\form.inc on line 993

kajal4ever’s picture

Have you solved this issue? If yes, please tell me how. I have got the same error and unable to solve. Please help.

Anonymous’s picture

The error's coming from form.inc which makes me think you're doing something like this:

$form['key'] = theme_table(...);

Whereas what you need to do is:

Drupal 6

$form['key'] => array('#value' => theme_table(...));

Drupal 7

$form['key'] => array('#markup' => theme_table(...));

Hope that helps