function poll_view_voting

Form constructor for the poll voting form.

Parameters

$node: The poll node object.

$block: (optional) TRUE if a poll should be displayed in a block. Defaults to FALSE.

See also

phptemplate_preprocess_poll_vote()

poll_vote()

Related topics

2 string references to 'poll_view_voting'
poll_block_latest_poll_view in drupal/core/modules/poll/poll.module
Returns the content for the 'latest poll' block.
poll_view in drupal/core/modules/poll/poll.module
Implements hook_view().

File

drupal/core/modules/poll/poll.module, line 723
Collects 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',
      '#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;
}