I am building an entity reference widget, which displays the reference link, next to the input field, to the target entity's edit form. I make it to open in a modal, with the following attributes on the link:
'class' => ['use-ajax'], 'data-dialog-type' => 'modal', 'data-dialog-options' => json_encode([ 'height' => 700, 'width' => 900, ]),
That works perfectly. However when I click submit on the modal form, I got redirected to the referenced entity view page, instead of the modal being closed and stay on the original form, where this widget is being used.
Is there any special attributes (like "data-dialog-type") which tells to the modal form's submit button to close the modal instead of redirecting to the original view?
Adding this to the URL actually pretty much solves the problem:
'query' => [ 'destination' => $this->requestStack->getCurrentRequest()->getRequestUri(), ],
This redirects the to the original page, with the potential values being updated (referenced item title), which is actually a pretty good thing!
That being said, I am still interested in the "ajax submit" version!