my custom form is working well. but when i want to call my custom form (in a custom mudule) via AJAX, the form tag is somehow not finished or broken.
<form class="myform" data-drupal-selector="myform" action="form_action_p_pvdeGsVG5zNF_XLGPTvYSKCf43t8qZYSwcfZl2uzM" method="post" id="myform" accept-charset="UTF-8">
instead of the form tag with all elements (data-drupal-form-fields="....."
) and action="/mypage"
they are all missing.
do i miss something when i build my form or is it just an issue with the core form api?
EDIT:
i found the part why its broke:
class FormController extends ControllerBase
{
public function createForm()
{
$form = \Drupal::formBuilder()->getForm(\Drupal\is_form\Form\MyForm::class);
// echo drupal_render($form); exit(); <--- this was before
return $form; //<--- this renders the whole page on callback from ajax, but the form tag is well
}
}
with my echo
statement only the form array is rendered, but not complete (form tag).
is there any method to render only my formfields, because the return
will give me the whole page page (with wrapper header footer and sidebars).
thanks in advantage