poll_more_choices_submit

function poll_more_choices_submit

poll_more_choices_submit($form, &$form_state)

Submit handler to add more choices to a poll form.

This handler is run regardless of whether JS is enabled or not. It makes changes to the form state. If the button was clicked with JS disabled, then the page is reloaded with the complete rebuilt form. If the button was clicked with JS enabled, then ajax_form_callback() calls poll_choice_js() to return just the changed part of the form.

File

modules/poll/poll.module, line 366
Enables your site to capture votes on different topics in the form of multiple choice questions.

Code

function poll_more_choices_submit($form, &$form_state) {
  // If this is a Ajax POST, add 1, otherwise add 5 more choices to the form.
  if ($form_state['values']['poll_more']) {
    $n = $_GET['q'] == 'system/ajax' ? 1 : 5;
    $form_state['choice_count'] = count($form_state['values']['choice']) + $n;
  }
  // Renumber the choices. This invalidates the corresponding key/value
  // associations in $form_state['input'], so clear that out. This requires
  // poll_form() to rebuild the choices with the values in
  // $form_state['node']->choice, which it does.
  $form_state['node']->choice = array_values($form_state['values']['choice']);
  unset($form_state['input']['choice']);
  $form_state['rebuild'] = TRUE;
}

© 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_more_choices_submit/7.x

在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号

意见反馈
返回顶部