Form submission handler for adding more than two choices to a poll.
This handler is run regardless of whether JavaScript is enabled. It makes changes to the form state. If the button is clicked with JavaScript disabled, then the page is reloaded with the complete rebuilt form. If the button was clicked with JavaScript enabled, then ajax_form_callback() calls poll_choice_js() to return just the changed part of the form.
function poll_more_choices_submit($form, &$form_state) {
// Add one more choice to the form.
if ($form_state['values']['poll_more']) {
$form_state['choice_count'] = count($form_state['values']['choice']) + 1;
}
// 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 $node->choice, which
// it does.
$node = $form_state['controller']
->getEntity($form_state);
$node->choice = array_values($form_state['values']['choice']);
unset($form_state['input']['choice']);
$form_state['rebuild'] = TRUE;
}