silverstripe / silverstripe-elemental

Create pages in Silverstripe CMS using content blocks
http://dna.co.nz
BSD 3-Clause "New" or "Revised" License
109 stars 115 forks source link

SPIKE Look at solutions between field validation conflicting between block level and page level #1204

Closed emteknetnz closed 2 months ago

emteknetnz commented 2 months ago

SPIKE to resolve https://github.com/silverstripe/silverstripe-elemental/issues/1179 and possibly also https://github.com/silverstripe/silverstripe-elemental/issues/1177

Currently when saving a page with an elemental area on it, the element data for all rendered elemental forms will be added to the POST request. This is a completely seperate code path from inline saving which uses FormBuilder/FormSchema

There are broadly two possible approaches here:

Timebox

3 days

Approach one:

Stop adding elemental data to the page POST request, and rely exclusively on using FormBuilder/FormSchema. On page save, block it on inline validating/saving the opened elemental forms

Approach two:

Keep elemental data in the page POST request. Somehow make the field validation message show in the correct place. Ineline elemental forms do not render by default so that'd need to be dynmically rendered when required.

Personally I (Steve) lean heavily towards approach one as it reduces complexity because there is now only one code path we need to look after, rather than two

New issues created

PRs

emteknetnz commented 2 months ago

I recommend we proceed with approach one, at a high level:

Approach one:

A pair of draft PRs implementing the core of this are linked in the description.

I strongly think this is the correct approach compared to approach two:

The linked PRs resolve the following two issues:

Approach two:

Broadly this would be implemented as:

I strongly dislike this approach compared to solution one:

emteknetnz commented 2 months ago

Team has agreed to proceed with approach one

New issues created to implement - https://github.com/silverstripe/silverstripe-elemental/issues/1215