It should be possible to submit forms via AHAH. But when validate or submit handlers call drupal_goto(), they break AHAH submission by forwarding to a new page before a JSON response can be returned.

To prepare the way for AHAH form submission, we should eliminate drupal_got() calls from form processing.

Form validate and submit handlers that call drupal_goto() include:

* comment_admin_overview_validate
* search_admin_settings_validate
* system_modules_uninstall_validate

Some of this may be fixable simply by replacing some drupal_goto() calls with setting $form_state['redirect'] as was done in #329660: drupal_goto() in node_configure_validate() is WRONG. But beyond that we'll need a broader solution.

Usually, drupal_goto() calls are designed to interrupt form processing. Probably we need the ability for a particular validate handler to designate a goto value. Then before going to the next validate handler we look for this value and respond accordingly.

CommentFileSizeAuthor
#10 357336-10.patch635 bytesvalthebald
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

starbow’s picture

+1 This is absolutely needed to free up the possibilities of how clientside ajax can interact with Drupal.
One of the things I played with in my old popups in D7 patch was breaking drupal_goto into two functions, one that calculated the path, and one that actually did the redirect. That way Ajax calls can receive the path of the next recommended page, and make their own decision on how to load that page, or how much of it to load. This also required putting a hook into drupal_redirect_form.

skilip’s picture

+1 for starbows approach! I did the same thing in my Floating Windows module. I did it using hook_form_alter, which is bad practice, I know... I'm very much willing to contribute to standardize popups functionality. Let me know if I can help!

sun’s picture

Title: Remove drupal_goto() calls from form validate and submit handlers--they break AHAH » Remove drupal_goto() calls from form validate and submit handlers - they break AHAH/AJAX
Priority: Normal » Critical
sun’s picture

Issue tags: +API clean-up

Introducing a new tag for feature freeze: API clean-up.

nedjo’s picture

#122130: Replace drupal_not_found() and drupal_access_denied() with constants is related in that it also removes a barrier to AJAX page loading.

rfay’s picture

Subscribing

sun.core’s picture

Version: 7.x-dev » 8.x-dev

This would have been nice to do in terms of the new AJAX framework in D7, but it's too late now.

catch’s picture

Priority: Critical » Major

Downgrading all D8 criticals to major per http://drupal.org/node/45111

Also this may be a duplicate of other issues like the actions one, but leaving open for now.

quicksketch’s picture

Title: Remove drupal_goto() calls from form validate and submit handlers - they break AHAH/AJAX » Remove drupal_goto() calls from system_modules_uninstall_validate()
Priority: Major » Normal

Form validate and submit handlers that call drupal_goto() include:

* comment_admin_overview_validate
* search_admin_settings_validate
* system_modules_uninstall_validate

The only one remaining as of Drupal 7.0 is system_modules_uninstall_validate(). This one also looks as though it would be an easy fix.

valthebald’s picture

Status: Active » Needs review
FileSize
635 bytes

it was :)

areke’s picture

Issue summary: View changes
Status: Needs review » Needs work
Issue tags: +Needs reroll

Unfortunately, this patch no longer applies. It should be rebased.

haithem_pro’s picture

Assigned: Unassigned » haithem_pro
Issue tags: +TUNIS_2013_DECEMBER

begin to work on

haithem_pro’s picture

Assigned: haithem_pro » Unassigned
Status: Needs work » Closed (fixed)

The code was refactored the same logic was reproduced in the method below so no need to apply the patch.

See below at line 128 core/modules/system/lib/Drupal/system/Form/ModulesUninstallForm.php

  public function validateForm(array &$form, array &$form_state) {
    // Form submitted, but no modules selected.
    if (!array_filter($form_state['values']['uninstall'])) {
      drupal_set_message($this->t('No modules selected.'), 'error');
      $form_state['redirect_route']['route_name'] = 'system.modules_uninstall';
    }
  }