I’m building a custom block and I’d like a custom error message for one of the fields. Is it possible to set a specific message for when the user hasn’t entered anything in the field?
Here’s the default error message when a required field isn’t filled out:
There’s an error on the “Text” field in block 1 using the “Heading” block type
This error message doesn’t communicate the issue well because of how my blocks field is setup.
Here is what my blueprint for the blocks field looks like:
heroTitle:
label: Title
type: blocks
required: true
empty: No hero title yet
max: 1
min: 1
fieldsets:
- heroHeading
Since I have set the fieldsets to one block type and I have maximum number of blocks of 1, the editor doesn’t need to select a block as the block field prepopulates with the only possible block type.
If I could change the required error message to something like “The hero title field is a required, please add a title”, that would be good.
I’m aware that I can overwrite the general error message for all required fields in the translations file but this would overwrite it for other fields which I don’t want.