function poll_validate in Drupal 4
Same name and namespace in other branches
- 5 modules/poll/poll.module \poll_validate()
- 6 modules/poll/poll.module \poll_validate()
- 7 modules/poll/poll.module \poll_validate()
Implementation of hook_validate().
File
- modules/
poll.module, line 104 - Enables your site to capture votes on different topics in the form of multiple choice questions.
Code
function poll_validate($node) {
if (isset($node->title)) {
// Check for at least two options and validate amount of votes:
$realchoices = 0;
// Renumber fields
$node->choice = array_values($node->choice);
foreach ($node->choice as $i => $choice) {
if ($choice['chtext'] != '') {
$realchoices++;
}
if ($choice['chvotes'] < 0) {
form_set_error("choice][{$i}][chvotes", t('Negative values are not allowed.'));
}
}
if ($realchoices < 2) {
form_set_error("choice][{$realchoices}][chtext", t('You must fill in at least two choices.'));
}
}
}