theme_poll_choices

Versions
6
theme_poll_choices($form)
7
theme_poll_choices($variables)

Theme the admin poll form for choices.

Related topics

Code

modules/poll/poll.module, line 664

<?php
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;
}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.