function theme_poll_choices
7.x poll.module | theme_poll_choices( |
6.x poll.module | theme_poll_choices($form) |
Theme the admin poll form for choices.
Related topics
1 theme call to theme_poll_choices()
- poll_form in drupal-6.x/
modules/ poll/ poll.module - Implementation of hook_form().
File
- drupal-6.x/
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;
}