Form submission in modal is throwing an error I have a Form which on submit calls another form via ajax and embeds it into a modal popup (Drupal8 standard) and when I click on submit of that modal form , I get a Drupal ajax error (I think it's due to the fact that ajax tries to find the from on the wrong page).

Here is how the submit button of the first form looks:

$form['table'][$pid]['edit'][$cid] = [
      '#type' =&gt; 'submit',
      '#id' =&gt; 'edit_'.$cid,
      '#name' =&gt; 'edit_'.$cid,
      '#value' =&gt; $this-&gt;t('Edit'),
      '#ajax' =&gt; [
        'callback' =&gt; [$this, 'customAjaxModalForm'],
        'event' =&gt; 'click',
      ],
  ];


And here's the customAjaxModalForm method, which calls the other form and modal.

public function customAjaxModalForm(array $form, FormStateInterface $form_state) {
  $response = new AjaxResponse();
  $modal_form = \Drupal::formBuilder()-&gt;getForm('\Drupal\accounts\Form\ContactsForm');    
  $response-&gt;addCommand(new OpenModalDialogCommand('Edit contact', $modal_form, ['width' =&gt; '800', 'height' =&gt; '300']));
  return $response;


}

Now the submit of the ContactsForm looks exactly as the submit above, as I need to send a few responses to the client (.js).

The rest of the code is pretty straight forward so I only supplied the most crucial parts.

How my code works, is: you go to a page, controller handles the request, it calls the first form (the form only has a textfield  and three submit buttons, the other two submit buttons work - do their job) the rest you know.

Any ideas? I am at a loss.
Ok, after a a few hours tinkering and extensive googling, i sadly found the answer i was looking for (but not hoping for).

How to open a popup form from a view link?

Turns out, in D8 this is impossible.