Non-inline validation only half works
Closed this issue · 2 comments
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
Chat GPT suggested using "standalone block" as the opposite of "inline block".
PR merged. Neeeeeeext!