So I'm migrating an existing 2.4 site to 3.1. Almost done. Just tidying up the CMS admin now.
One of the biggest challenges with this migration has been understanding the new GridField component. Or to be more precise, exactly how one can override the automatic scaffolding done when you edit/add a record. That is, how to customize the resulting form. Really, there is little in the docs, and many of the examples I have come across differ slightly.
Example. I have a Tour (extends Page). Tour has_many TourDate (extends DataObject). TourDate in turn has_one Tour. In 2.4 I had a ComplexTableField in getCMSFields on Tour. On getCMSFields_forPopup on TourDate, I am simple creating a FieldSet, pushing fields from TourDate onto it, and returning it.
With 3.1 and GridField however, it seems I have to use getCMSFields on TourDate. Get the parent getCMSFields, and then add to it using addFieldToTab. Which is fine, but for one thing.
The automatic scaffolding is adding a dropdown for the has_one Tour relationship at the top of the TourDate form. I have tried $fields->removeByName('Tour') and $fields->removeFieldFromTab('Root.Main', 'Tour') to no avail.
My question is am I doing this correctly? I've seen examples of people still using getCMSFields_forPopup in the dataobject. I've seen some method called getEditForm (but that might be cross over with ModelAdmin work I am doing). The relationship here should be added automatically as it was with ComplexTableField. I don't want a user to be able to change it on add/edit.
Pastes if it's easier: