Ajax POST forms without destination throw BrokenPostRequestException

Created on 24 April 2024, 12 months ago
Updated 17 September 2024, 7 months ago

Problem/Motivation

After the commit of ๐Ÿ› Form Builder does not fully allow Ajax GET requests Fixed , some forms in our setup are broken and lead to BrokenPostRequestException after submission.

This happens if the the form gets submitted via Ajax using POST and the destination is the form itself.
In such a case the URL changes from /foo to /foo?ajax_form=1&_wrapper_format=drupal_ajax.
I assume that these parameters cause the form_builder to set $ajax_form_request to TRUE when building the form. But now the current method isn't POST anymore but GET because of the redirect after submission.

Proposed resolution

I created a patch that solves the issue for us by limiting the check for an incomplete post to the method POST.

๐Ÿ› Bug report
Status

Needs work

Version

11.0 ๐Ÿ”ฅ

Component
Ajaxย  โ†’

Last updated about 1 hour ago

Created by

๐Ÿ‡ฉ๐Ÿ‡ชGermany mkalkbrenner ๐Ÿ‡ฉ๐Ÿ‡ช

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @mkalkbrenner
  • ๐Ÿ‡ฉ๐Ÿ‡ชGermany mkalkbrenner ๐Ÿ‡ฉ๐Ÿ‡ช
  • Status changed to Needs review 12 months ago
  • ๐Ÿ‡ฉ๐Ÿ‡ชGermany mkalkbrenner ๐Ÿ‡ฉ๐Ÿ‡ช
  • Status changed to Needs work 12 months ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    Thanks for reporting. Sounds like something that may need test coverage, 60/40 on that. Since it's a small change but is marked major.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia Sahana _N

    sahana _n โ†’ made their first commit to this issueโ€™s fork.

  • Merge request !9394Ajax POST forms โ†’ (Open) created by Sahana _N
  • Status changed to Needs review 8 months ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia Sahana _N

    Hi,

    I tried to reproduce the issue in Drupal 11. x and successfully the issue is reproduced.

    Reproducing steps
    1. Install Drupal Core 11.x
    2. Created the custom form with the file element.
    3. On submission called Ajax callback.

    I created an MR please review it.
    If there are any inaccuracies, I would greatly appreciate your suggestions for improvement.
    Thanks!!

  • Pipeline finished with Failed
    8 months ago
    Total: 562s
    #271835
  • Status changed to Needs work 8 months ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    Previously tagged for tests which still appear to be needed

    Also MR appears to be the same as the patch, was there any change?

  • Pipeline finished with Success
    8 months ago
    Total: 637s
    #272204
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia anchal_gupta

    I have test this issue with the latest merge request. Its working fine as per expectation.
    Also attach screenshot.

Production build 0.71.5 2024