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

Non-inline validation only half works #1155

Closed
emteknetnz opened this issue Mar 7, 2024 · 2 comments
Closed

Non-inline validation only half works #1155

emteknetnz opened this issue Mar 7, 2024 · 2 comments

Comments

@emteknetnz
Copy link
Member

emteknetnz commented Mar 7, 2024

While working on inline-validation for elemental it was discovered that the current state of validation for non-inline saving is pretty bad

Validation on page save

Page save is somewhat busted. MyBlock::validate() style validation does work .. however the validation message will show at the top of the page rather than on the element as described in this bug

MyBlock::getCMSCompositeValidator() aka RequiredFields validation doesn't seem to work, nor does FormField::validate() - I tried putting a UrlField on my block which has its own validate() method though I could save invalid values.

Validation on "not inline" block.

I assume that "not inline" block means setting private static $inline_editable = false;

It's just a regular DataObject EditForm at this point. It work much better than blocks on the Page EditForm, though RequiredFields is still a bit busted because instead of a nice red error message you get a red toast that says "validation error" and no indication of what's invalid.

Same issue with a toast showing when adding a message via Model::validate() using addError(), as opposed to addFieldError() which does work OK

Acceptance criteria

  • Validation rules for inline and non-inline block work the same. Any validation rule that would be triggered for an inline block will also be triggered if the block is not in-line.
  • Errors originating from individual form fields (e.g. an invalid URL in a UrlField) are picked up by both block types.
  • Saving/publishing a page will trigger validation on its child block if they are in a a dirty state.

Related

Multi PR CI

Note that the endtoend cms failures are existing

PRs

@maxime-rainville
Copy link
Contributor

Chat GPT suggested using "standalone block" as the opposite of "inline block".

@GuySartorelli
Copy link
Member

PR merged. Neeeeeeext!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants