silverstripe/silverstripe-elemental

Elemental block validation not triggered on page save if the block hasn't been expanded

Opened this issue · 1 comments

If I save the page without expanding the block, none of the validation seems to happen. e.g. with your test blocks from the description, I add the block and immediately save the page - it should trigger validation errors for the missing required fields but it doesn't.

Note that if you expand and collapse the block, the data is included in the page submission and therefore validated against correctly. This is only a problem when the block hasn't been expanded at all before clicking the save button.

Possible solution

We could always load the data for the form and render it, but just keep it hidden until the block gets expanded.

This would mean all page submissions would always include all data for all inline-editable blocks.
It would also mean we can do away with the logic we currently have for inline-saving blocks - we currently have logic to render a hidden form when inline-saving blocks (using the ... menu on the block) if the block wasn't expanded.

This would likely have a performance impact, especially for pages with a lot of blocks. We'd need to measure that.
That performance impact comes in two flavours:

  1. Page load time when loading the edit form for the page that owns the blocks
  2. Form submission time

We have too many elemental cards in flight right now. Let's have an architecture catch up about them.