poll_view_voting

Versions
4.6 – 4.7
poll_view_voting(&$node, $teaser, $page, $block)
5
poll_view_voting($node, $block)
6
poll_view_voting(&$form_state, $node, $block)
7
poll_view_voting($form, &$form_state, $node, $block = FALSE)

Generates the voting form for a poll.

See also

poll_vote()

@see phptemplate_preprocess_poll_vote()

Related topics

Code

modules/poll/poll.module, line 637

<?php
function poll_view_voting($form, &$form_state, $node, $block = FALSE) {
  if ($node->choice) {
    $list = array();
    foreach ($node->choice as $i => $choice) {
      $list[$i] = check_plain($choice['chtext']);
    }
    $form['choice'] = array(
      '#type' => 'radios',
      '#default_value' => -1,
      '#options' => $list,
    );
  }

  $form['vote'] = array(
    '#type' => 'submit',
    '#value' => t('Vote'),
    '#submit' => array('poll_vote'),
  );

  // Store the node so we can get to it in submit functions.
  $form['#node'] = $node;
  $form['#block'] = $block;

  // Set form caching because we could have multiple of these forms on
  // the same page, and we want to ensure the right one gets picked.
  $form_state['cache'] = TRUE;

  // Provide a more cleanly named voting form theme.
  $form['#theme'] = 'poll_vote';
  return $form;
}
?>
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.