function poll_validate
poll_validate($node, $form)
Implements hook_validate().
File
- modules/poll/poll.module, line 454
- Enables your site to capture votes on different topics in the form of multiple choice questions.
Code
function poll_validate($node, $form) { if (isset($node->title)) { // Check for at least two options and validate amount of votes. $realchoices = 0; foreach ($node->choice as $i => $choice) { if ($choice['chtext'] != '') { $realchoices++; } if (isset($choice['chvotes']) && $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.')); } } }
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/modules!poll!poll.module/function/poll_validate/7.x