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

Generates the voting form for a poll.

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

File

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

Code

function poll_view_voting($node, $block) {
  if ($node->choice) {
    $list = array();
    foreach ($node->choice as $i => $choice) {
      $list[$i] = check_plain($choice['chtext']);
    }
    $form['choice'] = array(
      '#type' => 'radios',
      '#title' => $block ? check_plain($node->title) : '',
      '#default_value' => -1,
      '#options' => $list,
    );
  }
  $form['nid'] = array(
    '#type' => 'hidden',
    '#value' => $node->nid,
  );
  $form['vote'] = array(
    '#type' => 'submit',
    '#value' => t('Vote'),
  );
  $form['#action'] = url('node/' . $node->nid);
  return $form;
}