You are here

function advpoll_ranking_validate_choices in Advanced Poll 7.2

Same name and namespace in other branches
  1. 7 advpoll_ranking/advpoll_ranking.module \advpoll_ranking_validate_choices()
1 string reference to 'advpoll_ranking_validate_choices'
advpoll_ranking_form_alter in advpoll_ranking/advpoll_ranking.module

File

advpoll_ranking/advpoll_ranking.module, line 93

Code

function advpoll_ranking_validate_choices($form, &$form_state) {
  $input_choices = array();
  $lang = $form_state['build_info']['args'][0]->language;
  if (!isset($form_state['input']['advpoll_choice'][$lang])) {
    $lang = 'und';
  }
  $choices = $form_state['input']['advpoll_choice'][$lang];
  foreach ($choices as $choice) {
    if ($choice['choice']) {
      $input_choices[] = $choice['choice'];
    }
  }
  $behavior = $form_state['input']['advpoll_behavior'][$lang];
  if (count($input_choices) > 10 && ($behavior == 'borda' || $behavior == 'runoff')) {
    form_set_error('advpoll_choice', t('A ranking poll may only have 10 choices.  Please remove some choices.'));
  }
}