Tuesday 12 March 2019

Add custom form in Custom block programmatically Drupal 8

Add Custom Form in custom block in Drupal 8

Now I am having a custom block and custom form. Now show/add this form on custom block.

With the help of following command, you can add existing form on custom block.
\Drupal::formBuilder()->getForm('Drupal\firstcustommodule\Form\CompanyAddForm');
 After adding above code in block build method, Existing form will start to appear on Custom block as shown in screenshot.

No comments:

Post a Comment