You are here

function theme_webform_grid in Webform 6.2

Same name and namespace in other branches
  1. 5.2 components/grid.inc \theme_webform_grid()
  2. 5 components/grid.inc \theme_webform_grid()
  3. 6.3 components/grid.inc \theme_webform_grid()
  4. 7.4 components/grid.inc \theme_webform_grid()
  5. 7.3 components/grid.inc \theme_webform_grid()
1 theme call to theme_webform_grid()
_webform_render_grid in components/grid.inc

File

components/grid.inc, line 376
Webform module grid component.

Code

function theme_webform_grid($grid_element) {
  $rows = array();
  $header = array(
    '',
  );
  $first = TRUE;
  foreach (element_children($grid_element) as $key) {
    $question_element = $grid_element[$key];

    // Set the header for the table.
    if ($first) {
      foreach ($question_element['#options'] as $option) {
        $header[] = $option;
      }
      $first = FALSE;
    }

    // Create a row with the question title.
    $row = array(
      check_plain($question_element['#title']),
    );

    // Render each radio button in the row.
    $radios = expand_radios($question_element);
    foreach (element_children($radios) as $key) {
      unset($radios[$key]['#title']);
      $row[] = drupal_render($radios[$key]);
    }
    $rows[] = $row;
  }
  return theme('form_element', $grid_element, theme('table', $header, $rows, array(
    'class' => 'webform-grid',
  )));
}