Skip to main content
3 of 3
Removed Drupal and version tag from title
leymannx
  • 18.8k
  • 6
  • 72
  • 126

Why is my theme table row array not being displayed?

I have the below code and I know both the $headers and the $html have values stored in them as i can echo them out. I can also set the 'header' => in the theme function to be either $header or $html and it will display the data.

However when I add in 'rows' =>, no data is displayed.

Can anyone see why?

function emnies_ad_hoc_query_exporter_get_html_formatted_ad_hoc_query_responses($obj_response) {
  $str_current_country = '';

  foreach ($obj_response as $response) {
    if ($str_current_country != $response->country) {
      $str_current_country = $response->country;
      $html = emnies_ad_hoc_query_exporter_get_country_row($str_current_country, $obj_response);
    }
  }
  $header = array('Country', 'Wider Dissemination', 'Responses'); 
  $output = theme('table', array(
    'header' => $header, 
    'rows' => $html
  ));
  return $output;
}



function emnies_ad_hoc_query_exporter_get_country_row($str_current_country, $obj_response) {
  $rows = array();
  $i = 0;
  foreach ($obj_response as $response) {
    if ($str_current_country == $response->country) {
      if ($i == 0) {
        $rows[] = $str_current_country;
        $rows[] = $response->wider_dissemination;
      }
      $i = $i + 1;
      $rows[] = $response->response;
    }
  }
  return $rows;
}
James
  • 29
  • 1
  • 7