summaryrefslogtreecommitdiff
path: root/modules/poll/poll.module
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2010-06-17 13:44:45 +0000
committerDries Buytaert <dries@buytaert.net>2010-06-17 13:44:45 +0000
commitcb043e8c489f033f7435e7fd5d18325155465c77 (patch)
tree716cdfe743aa99a01a1dce97cc800c00119af896 /modules/poll/poll.module
parent3620310d7c8a5d487f7b6826a89f8a4816149333 (diff)
downloadbrdo-cb043e8c489f033f7435e7fd5d18325155465c77.tar.gz
brdo-cb043e8c489f033f7435e7fd5d18325155465c77.tar.bz2
- Patch #735800 by effulgentsia, fago, Frando: node form triggers form level submit functions on button level submits, without validation. Oh yeah.
Diffstat (limited to 'modules/poll/poll.module')
-rw-r--r--modules/poll/poll.module11
1 files changed, 7 insertions, 4 deletions
diff --git a/modules/poll/poll.module b/modules/poll/poll.module
index f273953a4..d698e0301 100644
--- a/modules/poll/poll.module
+++ b/modules/poll/poll.module
@@ -366,15 +366,18 @@ function poll_form($node, &$form_state) {
* return just the changed part of the form.
*/
function poll_more_choices_submit($form, &$form_state) {
- include_once DRUPAL_ROOT . '/' . drupal_get_path('module', 'node') . '/node.pages.inc';
- // Set the form to rebuild and run submit handlers.
- node_form_submit_build_node($form, $form_state);
-
// Make the changes we want to the form state.
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;
}
function _poll_choice_form($key, $chid = NULL, $value = '', $votes = 0, $weight = 0, $size = 10) {