You are here

function theme_poll_choices in Drupal 6

Same name and namespace in other branches
  1. 7 modules/poll/poll.module \theme_poll_choices()

Theme the admin poll form for choices.

Related topics

1 theme call to theme_poll_choices()
poll_form in modules/poll/poll.module
Implementation of hook_form().

File

modules/poll/poll.module, line 658
Enables your site to capture votes on different topics in the form of multiple choice questions.

Code

function theme_poll_choices($form) {

  // Change the button title to reflect the behavior when using JavaScript.
  drupal_add_js('if (Drupal.jsEnabled) { $(document).ready(function() { $("#edit-poll-more").val("' . t('Add another choice') . '"); }); }', 'inline');
  $rows = array();
  $headers = array(
    t('Choice'),
    t('Vote count'),
  );
  foreach (element_children($form) as $key) {

    // No need to print the field title every time.
    unset($form[$key]['chtext']['#title'], $form[$key]['chvotes']['#title']);

    // Build the table row.
    $row = array(
      'data' => array(
        array(
          'data' => drupal_render($form[$key]['chtext']),
          'class' => 'poll-chtext',
        ),
        array(
          'data' => drupal_render($form[$key]['chvotes']),
          'class' => 'poll-chvotes',
        ),
      ),
    );

    // Add additional attributes to the row, such as a class for this row.
    if (isset($form[$key]['#attributes'])) {
      $row = array_merge($row, $form[$key]['#attributes']);
    }
    $rows[] = $row;
  }
  $output = theme('table', $headers, $rows);
  $output .= drupal_render($form);
  return $output;
}