silverstripe-admin icon indicating copy to clipboard operation
silverstripe-admin copied to clipboard

RFC: New React based replacement for GridFieldDetailForm

Open robbieaverill opened this issue 5 years ago • 6 comments

Affected Version

SilverStripe 4.x

Description

Coming from a GridField world

In SilverStripe 3.x, a developer could easily use GridField to scaffold a mechanism for editing a has_many/many_many list of data models (for example, on a page). This would provide a few features for free such as an edit form and a delete/unlink handler.

In SilverStripe 4.x we will be introducing React GridField, so this kind of situation will soon be viable in a React powered world as well (#556).

That said, in SilverStripe 4.x there isn't necessarily a good reason to use GridField to power interfaces like this any more (besides the additional functionality that GridField provides). One example is switching silverstripe-elemental to use a React/GraphQL driven editor UI from a PHP GridField.

Moving away from GridField

The problem with this issue is that once we remove GridField we also lose the built in edit form. Deleting, unlinking and other inline operations are easy enough to achieve with GraphQL mutations, but the edit form does many things; render on a standalone page in the CMS, render a form, render a field list of form fields. At this stage there isn't a drop in replacement for this, and this means that in situations like this we're going to continue to power the feature with GridField, while changing the UI entirely to be a bespoke mini React app.

Options

1. Wait for React GridField (#556) and tie that in instead

Presumably the React GridField will also come with an equivalent of the GridFieldDetailForm which does this.

Pros: the feature is already in development and will work out of the box, especially when ModelAdmins for example are all using this

Cons: it's still using GridField for the same reasons it did in SilverStripe 3.x (convenience)

2. Create something standalone for this

Noting because it was an option, but not a very good one (reusability, etc)

3. A centralised place for rendering FormBuilderLoader

Perhaps there could be something like /admin/edit/:classname/:ID which is a React controlled area that renders an edit form via FormBuilderLoader, including scaffolding all the CMS tabs etc. Designed to be entirely abstract, presumably you could edit any data model that you had permissions for...

It would need to allow extensibility for things like breadcrumbs, the back link, etc.

Would not be available as a CMS menu item.

Pros: centralised, reusable, React GridField could use it as well for the GridFieldDetailForm replacement

Cons: ?


It's also worth mentioning that at some point in the future, the CMS area itself will be React powered as well. At a high level, this will require the same thing as this - a React driven form editing area for pages.

I don't have a huge amount of ideas here, but thought I'd kick this off for discussion to start with.

robbieaverill avatar Aug 02 '18 03:08 robbieaverill