diff options
author | Angie Byron <webchick@24967.no-reply.drupal.org> | 2010-01-02 23:30:53 +0000 |
---|---|---|
committer | Angie Byron <webchick@24967.no-reply.drupal.org> | 2010-01-02 23:30:53 +0000 |
commit | 70e53b33c1074655f4ee917c0c4f4b1219bb109d (patch) | |
tree | 7033541b9bc09dfc85aa69be2b57a1f8c8fa9b85 /modules/poll/poll.module | |
parent | d4f4d3c32e2b7028527b13fc3d63d84576562590 (diff) | |
download | brdo-70e53b33c1074655f4ee917c0c4f4b1219bb109d.tar.gz brdo-70e53b33c1074655f4ee917c0c4f4b1219bb109d.tar.bz2 |
#370537 by chx, sun, effulgentsia, quicksketch, eaton, Heine, and yched: Allow buttons to only validate sections of forms, e.g. More buttons. (with tests)
Diffstat (limited to 'modules/poll/poll.module')
-rw-r--r-- | modules/poll/poll.module | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/modules/poll/poll.module b/modules/poll/poll.module index 9c48de6b6..42d7afc68 100644 --- a/modules/poll/poll.module +++ b/modules/poll/poll.module @@ -271,7 +271,8 @@ function poll_form($node, &$form_state) { '#value' => t('More choices'), '#description' => t("If the amount of boxes above isn't enough, click here to add more choices."), '#weight' => 1, - '#submit' => array('poll_more_choices_submit'), // If no javascript action. + '#limit_validation_errors' => array(array('choice')), + '#submit' => array('poll_more_choices_submit'), '#ajax' => array( 'callback' => 'poll_choice_js', 'wrapper' => 'poll-choices', @@ -322,9 +323,13 @@ function poll_form($node, &$form_state) { } /** - * Submit handler to add more choices to a poll form. This handler is used when - * javascript is not available. It makes changes to the form state and the - * entire form is rebuilt during the page reload. + * 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. */ function poll_more_choices_submit($form, &$form_state) { include_once DRUPAL_ROOT . '/' . drupal_get_path('module', 'node') . '/node.pages.inc'; @@ -379,7 +384,12 @@ function _poll_choice_form($key, $chid = NULL, $value = '', $votes = 0, $weight } /** - * Menu callback for AHAH additions. Render the new poll choices. + * Ajax callback in response to new choices being added to the form. + * + * This returns the new page content to replace the page content made obsolete + * by the form submission. + * + * @see poll_more_choices_submit() */ function poll_choice_js($form, $form_state) { return $form['choice_wrapper']['choice']; |