silverstripe/sapphire — pull request #939 by chillu (2012-11-08 00:41:11+00:00)
Title: NEW Many-many relation data editing in GridFieldDetailForm

Also adds GridFieldDetailForm->setFields() for customizing
the displayed form fields (required for adding relational fields).

Discussed API with Stig beforehand, we both agree that implicit namespacing isn't really the best API design, but also couldn't come up with a better way, given the limitations of the form API underneath.

The setup required by a dev is a bit of work at the moment, although its at least well documented.
In general, we could automatically scaffold in extra fields by reusing parts of FormScaffolder.
What do people think of this default? Might be confusing to have non-record fields show up in there, with pretty random field names like "ManyMany[MyRelationField]"?

Note that setFields() was a necessary addition, we can't simply add those extra fields to the record's own getCMSFields() implementation, since it might be used in other contexts as well. For example, a record might be edited as part of a ManyManyList in a GridFieldDetailForm, but elsewhere in a ModelAdmin as part of a standard DataList.