- last update
10 months ago Cancellation requested - last update
10 months ago Custom Commands Failed - last update
10 months ago Custom Commands Failed - last update
10 months ago Build Successful
When adding Form API #ajax parameter to a Link type element:
$form['link'] = [
'#type' => 'link',
'#title' => $this->t('AJAX link'),
'#url' => Url::fromRoute('ajax_example.example_form_ajax', [], ['query' => ['some_parameter' => 'some_value']]),
'#ajax' => [
'callback' => [$this, 'ajaxCallback'],
'wrapper' => $container_id,
],
];
, form values are not included in the AJAX request, resulting with a confusing error: "An unrecoverable error occurred. The uploaded file likely exceeded the maximum file size (50 MB) that this server supports." that has nothing to do with the actual problem and originates from \core\lib\Drupal\Core\Form\EventSubscriber\FormAjaxSubscriber.php.
This bug seriously limits development possibilities when using AJAX API, because the only way a link can influence a form is by adding query parameters to the FormBuilder as in my Ajax Example sandbox → , and always having to build a new form with empty storage etc, instead of working with the current form.
I checked the request object and when a link has #ajax parameter, the resulting request object has no form values in $request->query->parameters
, as opposed to a submit element for example. Solution most likely requires modifying javascript to include form values in the request.
Also it'd be good to change the error message to be more descriptive, as the problem has nothing to do with file uploads.
Needs work
11.0 🔥
Last updated
The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.
Not all content is available!
It's likely this issue predates Contrib.social: some issue and comment data are missing.