You are here

function theme_webform_grid in Webform 6.3

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.2 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
Implements _webform_render_component().

File

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

Code

function theme_webform_grid($element) {
  $rows = array();
  $header = array(
    array(
      'data' => '',
      'class' => 'webform-grid-question',
    ),
  );

  // Set the header for the table.
  foreach ($element['#grid_options'] as $option) {
    $header[] = array(
      'data' => _webform_filter_xss($option),
      'class' => 'checkbox webform-grid-option',
    );
  }
  foreach (element_children($element) as $key) {
    $question_element = $element[$key];

    // Create a row with the question title.
    $row = array(
      array(
        'data' => _webform_filter_xss($question_element['#title']),
        'class' => 'webform-grid-question',
      ),
    );

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