ajax form, send data from js modal to form I have the following form: 

When I click the "Add Filter" button, I need to open a modal with a select input element. Then I need to send the user's choice back to the Drupal Form instance and extend the original form, based on the user's input.

I'm not sure of the best way to do this. 2 options I've thought of are:


Is it possible to have the "Add Filter" ajax callback send an "OpenModalDialogCommand" with a new form, then have the new form "submitForm" method send the data to the original form? 
Another possibility would be to collect the data clientside and send it to the original form.


However I'm not sure how to get the user data into the original form in either of the options above.
I have worked on a similar case in D7.
Take a look at these tutorials.
https://www.deeson.co.uk/labs/insert-form-pop-modal-ctools-and-drupal-7
http://internetdevels.com/blog/big-manual-for-creating-ctools-popups-in-drupal-7