Problem/Motivation
Workspaces core adds validation handlers that prevent submission of any form that is not explicitly marked as safe via code from within a workspace. That also means that every time that an editor/site administrator needs to submit a form inside a workspace, a developer needs to mark the form as safe via code first, before forms can actually get submitted.
As discussed with Fabianx and amateescu, WSE should make this a bit easier by not denying form submission by default but rather prompting and warning the submitting user that the submissions happens inside a workspace.
Proposed resolution
When a form is submitted inside a workspace and not explicitly whitelisted on the settings form, a prompt asking the user for confirmation of the submission inside the workspace pops up and submission of the form happens only after hitting the confirmation button.
Certain forms may be whitelisted to not show the prompt. This happens via entering form ids on the WSE settings form. Further, some workspaces internal forms are hardcoded to never use the prompt as it doesn't make sense in this case.
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | Screen Recording 2565-10-14 at 15.28.12.gif | 2.39 MB | s_leu |
| #4 | Screenshot 2022-09-23 at 11.15.08.png | 112.53 KB | wroxbox |
| #4 | Screenshot 2022-09-23 at 11.07.41.png | 173.55 KB | wroxbox |
| #4 | Screenshot 2022-09-23 at 11.06.50.png | 237.67 KB | wroxbox |
Issue fork wse-3304460
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
s_leu commentedComment #4
wroxbox commentedThis patch adds a button but the UI is not working:

Clicking save leads to drupal error, internal error.
Clicking the left blue buttton opens a dialog:

But the save leads to drupal internal error and nothing is saved.
Seems that the markup for the button actually is not final:

Comment #5
amateescu commentedThanks for testing! Setting this to NW.
Comment #6
s_leu commentedOk I think this is ready for review again. The current code should work on all config forms now and it also supports switching to live and then back into the workspace the submission was triggered in.
According to my tests, there was just one problem: When submitting the "Manage form display" or "Manage display" forms, it appears as the changed values are saved. But refreshing the page after saving it from within a workspace, the changes are not loaded resp. it looks like they never get saved. Here a screencast that may make it more clear:
I didn't invest much time to dig into this problem yet as I'm not sure if it's better to just ignore these forms and mark them as exceptions which will have to be submitted in the live workspace. Any thoughts on this?
Comment #7
amateescu commentedCommitted a few code cleanups and merged the MR into 1.0.x, thanks for all the work on this!