Problem/Motivation
The node form is not validated/submitted if the workbench_moderation module is enabled and configured along with the Gutenberg settings on.
Steps to reproduce
Consider the Basic page for this case,
- Enable the "Gutenberg" for the "Basic page" content type
- Download and install workbench and workbench_moderation
- Enable the Moderation for "Basic Page" with the default settings.
- Now open a form to add the content of type "Basic page" (node/add/page)
- Click on any Moderation state button. With the default setup, edit page will have three "Moderation state" for the user 1, They are listed as follows,
- Save and Create New Draft
- Save and Request Review
- Save and Publish
- There will be no validation + no submission
Proposed resolution
The ninja hacks added to stop form to submission as every button in Gutenberg will cause the submit event.
For this to handle, I propose use of the drupalSettings library and adding/updating the submit action element with the "id" attribute. This way, the other modules which add the action buttons to the node form will share those ids vai hook_page_attachments_alter() implementation.
e.g.
/**
* Implements hook_page_attachments_alter().
*/
function workbench_moderation_page_attachments_alter(array &$page) {
$options = ['edit-submitted', 'edit-draft'];
$page['#attached']['drupalSettings']['gutenberg']['nodeActions'] = $options;
}
And the gutenberg.js will capture these, and the form will functions as expected.
Issue fork gutenberg-3221238
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:
- 3221238-the-node-form
changes, plain diff MR !9
Comments
Comment #2
rahul.shindeComment #3
rahul.shindeComment #5
rahul.shindeComment #6
rahul.shindeComment #7
rahul.shindeComment #8
codebymikey commentedThis appears to be a duplicate of #3185886: Support various submit action buttons