diff --git a/core/lib/Drupal/Core/Form/FormBuilder.php b/core/lib/Drupal/Core/Form/FormBuilder.php index a0ba52c..8581198 100644 --- a/core/lib/Drupal/Core/Form/FormBuilder.php +++ b/core/lib/Drupal/Core/Form/FormBuilder.php @@ -604,9 +604,11 @@ public function processForm($form_id, &$form, FormStateInterface &$form_state) { } /** - * #lazy_builder callback; gets an actual path for the path. + * #lazy_builder callback; this renders a placeholder that's used in a form + * action to use the current request's url * - * @return string + * @return array + * A renderable array representing the form action. */ public function renderPlaceholderFormAction() { return ['#link' => $this->buildFormAction()]; @@ -626,7 +628,11 @@ public function prepareForm($form_id, &$form, FormStateInterface &$form_state) { $placeholder_render_array = [ '#lazy_builder' => ['form_builder:renderPlaceholderFormAction', []], ]; + + // Attach the lazy builder to the form and add the placeholder in the form + // action so the #lazy_builder callback knows what to replace. $form['#attached']['placeholders'][$placeholder] = $placeholder_render_array; + $form['#action'] = $placeholder; } // Fix the form method, if it is 'get' in $form_state, but not in $form.