function advpoll_js_more_choices in Advanced Poll 6
Same name and namespace in other branches
- 6.3 advpoll.module \advpoll_js_more_choices()
- 6.2 advpoll.module \advpoll_js_more_choices()
AHAH handling of the more choices button.
Based on http://drupal.org/node/331941
1 string reference to 'advpoll_js_more_choices'
- advpoll_menu in ./
advpoll.module - Implementation of hook_menu().
File
- ./
advpoll.module, line 1671 - Advanced Poll - a sophisticated polling module for voting, elections, and group decision-making.
Code
function advpoll_js_more_choices() {
// We're starting in step #3, preparing for #4.
$form_state = array(
'storage' => NULL,
'submitted' => FALSE,
);
$form_build_id = $_POST['form_build_id'];
// Step #4.
$form = form_get_cache($form_build_id, $form_state);
// Preparing for #5.
$args = $form['#parameters'];
$form_id = array_shift($args);
$form_state['post'] = $form['#post'] = $_POST;
$form['#programmed'] = $form['#redirect'] = FALSE;
// Step #5.
drupal_process_form($form_id, $form, $form_state);
// Step #6 and #7 and #8.
$form = drupal_rebuild_form($form_id, $form_state, $args, $form_build_id);
// Step #9.
$choice_form = $form['choice_wrapper']['choice'];
unset($choice_form['#prefix'], $choice_form['#suffix']);
$output = theme('status_messages') . drupal_render($choice_form);
// Final rendering callback.
drupal_json(array(
'status' => TRUE,
'data' => $output,
));
}