Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to do validation of the metabox forms on Save or Publish #8272

Closed
dev4press opened this issue Jul 29, 2018 · 10 comments
Closed

How to do validation of the metabox forms on Save or Publish #8272

dev4press opened this issue Jul 29, 2018 · 10 comments
Labels
[Type] Question Questions about the design or development of the editor.

Comments

@dev4press
Copy link

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.

@designsimply designsimply added the [Type] Question Questions about the design or development of the editor. label Jul 30, 2018
@designsimply
Copy link
Member

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? 🙂

@chrisvanpatten
Copy link
Contributor

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

@dev4press
Copy link
Author

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

@aduth
Copy link
Member

aduth commented Sep 13, 2018

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:

@timnolte
Copy link
Contributor

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.

@awps
Copy link
Contributor

awps commented Aug 29, 2020

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. :(

@gitgetgotgotten
Copy link

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. :(

We are on the verge of 2022. Hasn't it been fixed yet?

@tellthemachines
Copy link
Contributor

The lockPostSaving action might be of use here. You could add some custom validation logic and then unlock saving only if it passes.

@t-hamano
Copy link
Contributor

The lockPostSaving action might be of use here. You could add some custom validation logic and then unlock saving only if it passes.

I also think that this problem can be solved by using this API. You could just detect a change in any field of the form and dispatch it via lockPostSaving or unlockPostSaving. Sample code is also present here:

Therefore, I would like to close this issue, but if there is anything I have missed, please comment.

@t-hamano t-hamano closed this as not planned Won't fix, can't repro, duplicate, stale Dec 17, 2023
@timnolte
Copy link
Contributor

Really, so this is just being left by the wayside? So functionality is broken and now completely abandoned by new development.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Question Questions about the design or development of the editor.
Projects
None yet
Development

No branches or pull requests

9 participants