You are here

function _webform_display_grid in Webform 7.3

Same name and namespace in other branches
  1. 6.3 components/grid.inc \_webform_display_grid()
  2. 7.4 components/grid.inc \_webform_display_grid()

Implements _webform_display_component().

File

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

Code

function _webform_display_grid($component, $value, $format = 'html') {
  $questions = _webform_select_options_from_text($component['extra']['questions'], TRUE);
  $options = _webform_select_options_from_text($component['extra']['options'], TRUE);
  $element = array(
    '#title' => $component['name'],
    '#weight' => $component['weight'],
    '#format' => $format,
    '#grid_questions' => $questions,
    '#grid_options' => $options,
    '#theme' => 'webform_display_grid',
    '#theme_wrappers' => $format == 'html' ? array(
      'webform_element',
    ) : array(
      'webform_element_text',
    ),
    '#sorted' => TRUE,
    '#translatable' => array(
      '#title',
      '#grid_questions',
      '#grid_options',
    ),
  );
  foreach ($questions as $key => $question) {
    if ($question !== '') {
      $element[$key] = array(
        '#title' => $question,
        '#value' => isset($value[$key]) ? $value[$key] : NULL,
        '#translatable' => array(
          '#title',
          '#value',
        ),
      );
    }
  }
  return $element;
}