You are here

function poll_view_voting in Drupal 5

Same name and namespace in other branches
  1. 4 modules/poll.module \poll_view_voting()
  2. 6 modules/poll/poll.module \poll_view_voting()
  3. 7 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;
}