ajax error when displaying a webform with address field

Created on 13 September 2022, about 3 years ago
Updated 16 January 2023, over 2 years ago

I get an ajax error trying to fill out a webform on a view_mode_page.
Specifically with an address field on the webform.
When selecting a country, it ajax-submits to fetch the correct address fields.
That one errors out with the cryptic "An unrecoverable error occurred. The uploaded file likely exceeded the maximum file size (@size) that this server supports."
There are no file uploads whatsoever on my webform...

The webform itself works fine when using directly through webform.
It also works fine when using it placed via a block or paragraphs on a page.
It only fails when using it on a display mode rendered through view_mode_page.

I managed to debug it to view_mode_page: MainController.php: displayEntity(): line 89:
$response = $this->httpKernel->handle($sub_request, HttpKernelInterface::SUB_REQUEST);
But I'm stuck debugging this any further...

Could someone help to get this fixed?

🐛 Bug report
Status

Active

Version

4.0

Component

Code

Created by

🇧🇪Belgium weseze

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇪🇪Estonia minff

    I can confirm that this issue persists and effectively renders webforms used in view mode page not usable if they require any Ajax (such as adding another element). The Ajax URL in the JSON code points to the main view mode and therefore results in a JS error.

    Setup in my case: the content type has several view modes activated, with the default view mode not having any webforms (node/1), while other view modes rendering webforms (node/1/application, for example). Webforms function normally outside of the view mode but since the Ajax call points to the default view mode (node/1) when making the call, it results in an error.

    The issue indeed comes from the \Drupal\Core\Render\Element\RenderElement::preRenderAjaxForm() returning the default view mode URL, as pointed out by the previous commenter. Haven't found any non-dirty fixes thus far.

  • 🇦🇺Australia nigelcunningham Geelong

    I think I've just come across another variation of this issue in the bug I reported (exposed filter in a layout on a view mode page). I also traced the issue to the path returning the canonical URL for the parent path. I'm still investigating but I am currently wondering whether the right behaviour would be to define a route for each view mode page.

  • 🇦🇺Australia nigelcunningham Geelong

    In my case, the issue was that the module makes the parameters for the subrequest be entity type, entity id and view mode. This prevents the Context code from recognising the contexts it would have found in the original request (in my case a group), so the content doesn't display because the views parameters that get their contextual arguments from the request context aren't satisfied.

    I have a module that seeks to set the group context in situations where the context might not be obvious. I had it disabled because I was wondering whether I really needed the code. It makes things work again.

    All of this leads me to the conclusion that view_mode_page needs a fundamental change to work properly - I think it should perhaps provide dynamic routes that directly invoke the entity view controller. Unfortunately I don't have the time at the moment to make a patch that does that.

Production build 0.71.5 2024