4.6.x poll.module poll_view_voting(&$node, $teaser, $page, $block)
4.7.x poll.module poll_view_voting(&$node, $teaser, $page, $block)
5.x poll.module poll_view_voting($node, $block)
6.x poll.module poll_view_voting(&$form_state, $node, $block)
7.x poll.module poll_view_voting($form, &$form_state, $node, $block = FALSE)

Generates the voting form for a poll.

See also

poll_vote()

phptemplate_preprocess_poll_vote()

Related topics

5 string references to 'poll_view_voting'
FieldUpdatePathTestCase::testFilledUpgrade in modules/simpletest/tests/upgrade/update.field.test
Tests that the update is successful.
hook_field_extra_fields in modules/field/field.api.php
Exposes "pseudo-field" components on fieldable entities.
poll_block_latest_poll_view in modules/poll/poll.module
Return content for 'latest poll' block.
poll_field_extra_fields in modules/poll/poll.module
Implements hook_field_extra_fields().
poll_view in modules/poll/poll.module
Implements hook_view().

File

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

Code

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',
      '#title' => t('Choices'),
      '#title_display' => 'invisible',
      '#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;
}