Gutenberg: How to do validation of the metabox forms on Save or Publish

Created on 29 Jul 2018  路  6Comments  路  Source: WordPress/gutenberg

Saving in Gutenberg is done through AJAX, so browsers do not get the trigger to validate the forms that may be in the metaboxes, so if the metabox form has fields that are required or need some other validation, they will not be validated.

Maybe adding a standard feature in Gutenberg to run HTML validation for metaboxes when the user clicks Save or Publish buttons in Gutenberg? Without that, there will be a lot of issues with submitting valid input from metaboxes that need validation. If not, is there a way in with Gutenberg to stop saving of draft or stop publishing until the validation of forms is completed? Something that can be used in JavaScript or even with jQuery to intercept Save/Publish, to run validation first.

[Type] Question

Most helpful comment

I find it very surprising that with all of the work being done with the Block Editor that it's been over a year and this is still an outstanding issue.

All 6 comments

There is a long discussion about server-side awareness of blocks and I think this issue would be better if added to that discussion. Can we close this in favor of moving it to #2751? If not, can you explain why so I can get a better understanding? 馃檪

@designsimply this is about metaboxes, not blocks, so it鈥檚 unrelated to #2751.

This is browser validation problem and the fact that Gutenberg effectively eliminates the browser validation before the data is submitted.

Related: #7020

Maybe adding a standard feature in Gutenberg to run HTML validation for metaboxes when the user clicks Save or Publish buttons in Gutenberg?

There may be an option here for using validation API as a condition prior to save:

I find it very surprising that with all of the work being done with the Block Editor that it's been over a year and this is still an outstanding issue.

I find it very surprising that with all of the work being done with the Block Editor that it's been over a year and this is still an outstanding issue.

Another year and this issue is still open. :(

Was this page helpful?
0 / 5 - 0 ratings

Related issues

pfefferle picture pfefferle  路  3Comments

JohnPixle picture JohnPixle  路  3Comments

franz-josef-kaiser picture franz-josef-kaiser  路  3Comments

ellatrix picture ellatrix  路  3Comments

youknowriad picture youknowriad  路  3Comments