function poll_validate

Implements hook_validate().

File

drupal/core/modules/poll/poll.module, line 452
Collects votes on different topics in the form of multiple choice questions.

Code

function poll_validate($node, $form) {
  if ($node
    ->label()) {

    // Check for at least two options and validate amount of votes.
    $realchoices = 0;
    foreach ($node->choice as $i => $choice) {
      if ($choice['chtext'] != '') {
        $realchoices++;
      }
    }
    if ($realchoices < 2) {
      form_set_error("choice][{$realchoices}][chtext", t('You must fill in at least two choices.'));
    }
  }
}