| Versionen | |
|---|---|
| drupal6 – drupal7 | theme_poll_choices($form) |
Theme the admin poll form for choices.
modules/
<?php
function theme_poll_choices($form) {
drupal_add_tabledrag('poll-choice-table', 'order', 'sibling', 'poll-weight');
$delta = 0;
$rows = array();
$headers = array(
'',
t('Choice'),
t('Vote count'),
t('Weight'),
);
foreach (element_children($form) as $key) {
$delta++;
// Set special classes for drag and drop updating.
$form[$key]['weight']['#attributes']['class'] = 'poll-weight';
// Build the table row.
$row = array(
'data' => array(
array('class' => 'choice-flag'),
drupal_render($form[$key]['chtext']),
drupal_render($form[$key]['chvotes']),
drupal_render($form[$key]['weight']),
),
'class' => 'draggable',
);
// Add any additional classes set on the row.
$row['class'] .= isset($form[$key]['#attributes']['class']) ? ' ' . $form[$key]['#attributes']['class'] : '';
$rows[] = $row;
}
$output = theme('table', $headers, $rows, array('id' => 'poll-choice-table'));
$output .= drupal_render_children($form);
return $output;
}
?>
Kommentare
Kommentar hinzufügen