@@ -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