You are here

function poll_view_voting in Drupal 6

Same name and namespace in other branches
  1. 4 modules/poll.module \poll_view_voting()
  2. 5 modules/poll/poll.module \poll_view_voting()
  3. 7 modules/poll/poll.module \poll_view_voting()

Generates the voting form for a poll.

See also

poll_vote()

phptemplate_preprocess_poll_vote()

Related topics

1 string reference to 'poll_view_voting'
poll_view in modules/poll/poll.module
Implementation of hook_view().

File

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

Code

function poll_view_voting(&$form_state, $node, $block) {
  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['#cache'] = TRUE;

  // Provide a more cleanly named voting form theme.
  $form['#theme'] = 'poll_vote';
  return $form;
}