Problem/Motivation
Settings Tray and the Workflow initiative are essentially solving the same common problems with using forms in AJAX dialogs (#2785047: In Outside In mode, form validation messages should appear in the off-canvas tray, not the main page and #2830584: Use modals for creating, updating, and deleting workflows, with a new DialogFormTrait, respectively).
The problems were:
- Showing validation messages on form submit error while remaining in the dialog
- Refreshing the main page when needed
- Redirect to a path on successful commit
Proposed resolution
Provide a common trait that can be used simply by including the trait and $this->buildFormDialog($form, $form_state, FALSE, '#drupal-modal');
(with the last 2 arguments being optional).
Remaining tasks
?
User interface changes
None.
API changes
API addition.
Data model changes
None.
Comment | File | Size | Author |
---|---|---|---|
#18 | 2896535-18.patch | 9.08 KB | timmillwood |
#18 | interdiff-2896535-18.txt | 767 bytes | timmillwood |
Comments
Comment #2
tedbowPatch with trait from #2830584-120: Use modals for creating, updating, and deleting workflows, with a new DialogFormTrait and #2785047-69: In Outside In mode, form validation messages should appear in the off-canvas tray, not the main page
Added generic tests(originally from Settings Tray) but I think they will fail now.
Comment #4
Wim LeersClarified IS.
Comment #5
Wim LeersI'd be forced to repeat all of the review points that @effulgentsia raised at #2896535: Create a helper trait for Forms in ajax dialogs, especially #2896535: Create a helper trait for Forms in ajax dialogs. Which means we're repeating the same discussion we already had.
Either this should be postponed on #2785047: In Outside In mode, form validation messages should appear in the off-canvas tray, not the main page and #2830584: Use modals for creating, updating, and deleting workflows, with a new DialogFormTrait, or those two issues must be closed in favor of this. I'm assuming the former. If it's the latter, then I'll leave it to @tedbow to mark those two issues as duplicates and reopen this.
Comment #7
tim.plunkettThis soft-blocks Layout Builder.
Comment #8
xjm#2830584: Use modals for creating, updating, and deleting workflows, with a new DialogFormTrait is just adding a trait to its own namespace currently. What is the plan WRT the layout builder?
Comment #9
almaudoh CreditAttribution: almaudoh commentedJust passing thru, but I couldn't resist...:)
Comment #11
timmillwoodMaybe as a first step we could move
\Drupal\layout_builder\Controller\AjaxHelperTrait
to core.Then look at adding items from
\Drupal\layout_builder\Form\AjaxFormHelperTrait
and #2830584: Use modals for creating, updating, and deleting workflows, with a new DialogFormTrait in a follow up?Comment #12
timmillwoodHere's a start for that.
I updated the patch in #2830584: Use modals for creating, updating, and deleting workflows, with a new DialogFormTrait so that the trait added there is now just a copy of the two LB traits, which will make the transition easier.
Comment #13
tim.plunkettPlease also remove the @todo in this file that points to this issue :)
Comment #14
timmillwoodLets add
AjaxFormHelperTrait
to the patch, and update settings tray to use it.Still todo:
- Make
AjaxHelperTrait::isAjax
less brittle.@tedbow suggested
Comment #15
timmillwoodNeeds work based on the todo in #14 and the change record.
Comment #16
timmillwoodYesterday I started work on #2949991: Add workspace UI in top dialog and quickly found I needed an
isAjax()
method, yet again copying the trait from LB. Although this time fully understanding how brittle it is, because I needed to adddrupal_dialog.off_canvas_top
to the array of wrapper formats.Comment #17
timmillwoodI've created a change record for this https://www.drupal.org/node/2950404
Comment #18
timmillwoodHere's an update to make
isAjax()
less brittle.Comment #19
tim.plunkettShould these still be marked @internal?
The changes to isAjax look good!
Comment #20
tim.plunkett@timmillwood points out that while we can always remove the @internal later, if we remove it now we're stuck. Better safe than sorry, and revisit that after issues like #2830584: Use modals for creating, updating, and deleting workflows, with a new DialogFormTrait and #2949991: Add workspace UI in top dialog land.
Comment #21
alexpottCommitted 9f61972 and pushed to 8.6.x. Thanks!
+1 for leaving internal for now as that does give us a chance to explore what's necessary to make this even more generic in #2830584: Use modals for creating, updating, and deleting workflows, with a new DialogFormTrait. Considering they are internal I think we should hold of publishing the CR until they are not.
There was an used use and a comment that needed properly re-flowing.
Comment #23
alexpottComment #25
quietone CreditAttribution: quietone at PreviousNext commentedpublish the change record