Render form in Drupal 8.
In modulename.routing.yml
modulename.fp:
path: '/formpage'
defaults:
_controller: '\Drupal\modulename\Controller\*Controller::formpage'
Write code in controller.php
public function formpage() {
$form = '';
$form = 'Form Title';
$form .= \Drupal::formBuilder()->getForm('\Drupal\modulename\Form\fp');
return [
'#type' => 'markup',
'#markup' => $form,
];
}
and write form code in modules\modulename\src\Form\fp.php.
but showing Form Title Array
how to render form.