3 namespace Drupal\block_test\Controller;
5 use Drupal\Core\Controller\ControllerBase;
6 use Drupal\Core\Form\FormState;
9 * Controller for block_test module
11 class TestMultipleFormController extends ControllerBase {
13 public function testMultipleForms() {
14 $form_state = new FormState();
16 'form1' => $this->formBuilder()->buildForm('\Drupal\block_test\Form\TestForm', $form_state),
17 'form2' => $this->formBuilder()->buildForm('\Drupal\block_test\Form\FavoriteAnimalTestForm', $form_state),
20 // Output all attached placeholders trough drupal_set_message(), so we can
21 // see if there's only one in the tests.
22 $post_render_callable = function ($elements) {
24 preg_match_all('<form\s(.*?)action="(.*?)"(.*)>', $elements, $matches);
26 $action_values = $matches[2];
28 foreach ($action_values as $action_value) {
29 drupal_set_message('Form action: ' . $action_value);
34 $build['#post_render'] = [$post_render_callable];