Steps to reproduce:

* Apply attached patch. It contains a new widget for entity_browser_example 'nodes' widget
* Install entity_browser_example
* Visit node/add/entity_browser_test
* Open NODES fieldset and click on "Select entities"
* Change the select option to "Create node"
* Do not enter any value. Submit the form. The modal is silently closed.

Comments

jonhattan created an issue. See original summary.

jonhattan’s picture

jonhattan’s picture

Title: Modal display doesn't validate » Modal display skips validation
slashrsm’s picture

I can confirm I am able to reproduce this. It proves how broken is current Modal display. :)

At NYC camp we had a discussion about it and kind of agreed that it would probably make sense to display an iframe in modal. It is not the nicest solution, but will probably cause the least problems on the long run. D7 does the same thing and it works just fine. This bug might be fixed if we end up going down this route (validation works fine in iframe display).

Thoughts?

jonhattan’s picture

I have no idea where to start with showing an iframe in a modal. Any clue is appreciated.
My script kiddie plan was to compare with entity_embed and try to come up with a fix...

slashrsm’s picture

This might be a good source of initial information:

https://www.drupal.org/node/1989646

jonhattan’s picture

This CR helps to clean up a bit the link generation, but that's all.

The problem is with the dialog submission: the modal display ajaxifies the Select button, and the ajax callback just update the selected entities and closes the dialog, no matter validation errors https://github.com/drupal-media/entity_browser/blob/8.x-1.x/src/Plugin/E...

I'm trying several things, one of those is ensuring validation Drupal\entity_browser_entity_form\Plugin\EntityBrowser\Widget\EntityForm::validate in a similar way as it's done in the sibling submit() method, with no luck still.

I suspect validation is done and we have some validation errors that need to pick somehow in the ajaxified submit callback. Still investigating ...

btw, the best source of info about ajax and forms I've found so far is core/modules/system/tests/modules/ajax_test.

jose reyero’s picture

Status: Active » Needs review
StatusFileSize
new1.39 KB

It seems the ajax callback doesn't check for errors and always closes the form.

This patch prints out the form again if there are any errors. (Reusing the same wrapper used by the DropDown widget selector).

slashrsm’s picture

Status: Needs review » Fixed

Committed.

  • slashrsm committed 4a55715 on 8.x-1.x authored by Jose Reyero
    Issue #2548969 by jonhattan, Jose Reyero: Modal display skips validation
    

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.