summaryrefslogtreecommitdiff
path: root/modules/poll/poll.module
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2010-09-09 23:01:48 +0000
committerDries Buytaert <dries@buytaert.net>2010-09-09 23:01:48 +0000
commiteaee909a00a516d864da65e44f8abe5446914c7e (patch)
treef3c52d3b9041e93a8e7000446016cc73b9413f2d /modules/poll/poll.module
parenta16c46bf8a99745d7fa31cc6f2c34e0b17e7bed6 (diff)
downloadbrdo-eaee909a00a516d864da65e44f8abe5446914c7e.tar.gz
brdo-eaee909a00a516d864da65e44f8abe5446914c7e.tar.bz2
- Patch #757154 by sun, effulgentsia: base form_id() via hook_forms() not taken into account for #validate, #submit, hook_form_FORMID_alter().
Diffstat (limited to 'modules/poll/poll.module')
-rw-r--r--modules/poll/poll.module11
1 files changed, 8 insertions, 3 deletions
diff --git a/modules/poll/poll.module b/modules/poll/poll.module
index 1de52b55f..72cd86e66 100644
--- a/modules/poll/poll.module
+++ b/modules/poll/poll.module
@@ -240,6 +240,8 @@ function poll_form($node, &$form_state) {
$type = node_type_get_type($node);
+ // The submit handlers to add more poll choices require that this form is
+ // cached, regardless of whether AJAX is used.
$form_state['cache'] = TRUE;
$form['title'] = array(
@@ -359,7 +361,7 @@ function poll_form($node, &$form_state) {
* return just the changed part of the form.
*/
function poll_more_choices_submit($form, &$form_state) {
- // Make the changes we want to the 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;
@@ -424,10 +426,13 @@ function poll_choice_js($form, $form_state) {
}
/**
- * Renumber fields and create a teaser when a poll node is submitted.
+ * Form submit handler for node_form().
+ *
+ * Upon preview and final submission, we need to renumber poll choices and
+ * create a teaser output.
*/
function poll_node_form_submit(&$form, &$form_state) {
- // Renumber fields
+ // Renumber choices.
$form_state['values']['choice'] = array_values($form_state['values']['choice']);
$form_state['values']['teaser'] = poll_teaser((object) $form_state['values']);
}