Skip to content

Commit 152d763

Browse files
author
Dominic Tubach
committed
Execute process callbacks of element type
Previously the code to process the #ajax attribute wasn't executed.
1 parent 5c31bd8 commit 152d763

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

src/Form/Control/Callbacks/RecalculateCallback.php

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,30 @@ public static function addAjaxCommands(AjaxResponse $response, FormStateInterfac
4444
*
4545
* @return array<int|string, mixed>
4646
*/
47-
public static function processElement(array $element, FormStateInterface $formState): array {
47+
public static function processElement(array &$element, FormStateInterface &$formState): array {
4848
if (TRUE !== $formState->get('$calculateUsed')) {
4949
if (is_array($element['#ajax'] ?? NULL) && [static::class, 'onChange'] === $element['#ajax']['callback']) {
5050
unset($element['#ajax']);
5151
}
5252
}
5353

54+
if (isset($element['#type'])) {
55+
assert(is_string($element['#type']));
56+
/** @var \Drupal\Core\Render\ElementInfoManagerInterface $elementInfoManager */
57+
$elementInfoManager = \Drupal::service('plugin.manager.element_info');
58+
$info = $elementInfoManager->getInfo($element['#type']);
59+
foreach ($info['#process'] ?? [] as $callback) {
60+
$completeForm = &$formState->getCompleteForm();
61+
/** @var array<int|string, mixed> $element */
62+
// @phpstan-ignore parameterByRef.type
63+
$element = call_user_func_array(
64+
// @phpstan-ignore argument.type
65+
$formState->prepareCallback($callback),
66+
[&$element, &$formState, &$completeForm]
67+
);
68+
}
69+
}
70+
5471
return $element;
5572
}
5673

0 commit comments

Comments
 (0)