Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Accessing gridfieldconfig in modeladmin

Go to End

4 Posts   2971 Views


Community Member, 52 Posts

5 July 2012 at 6:49pm

Hi there,

I'm trying to customise the gridfield that Model admin uses to manage dataobjects. I know i can use searchable_fields and summaray_fields etc to customise it a bit. Would anyone know how would I go about accessing the gridfieldconfig to add gridfield components?




Forum Moderator, 1391 Posts

5 July 2012 at 11:48pm

The GridField is created in ModelAdmin->getEditForm(). This function does it all: create the config, create the field and then create and return the Form that holds the field. There doesn't seem to be an easy way to 'intercept' the creation of the config. The getEditForm function can be decorated - but from there you'll have to access the form already created - so you might be able to do something like this (if by chance I understand it correctly):

// suppose the DataObject involved is called 'MyDataObject' 

Or (faster, maybe less complex but just not as nice) copy the entire function to your class MyDataObject_Admin extends ModelAdmin { ... }


Community Member, 52 Posts

6 July 2012 at 4:22pm

Hey great, thanks I'll give it a shot and post back


Community Member, 156 Posts

20 July 2012 at 1:41am

If anyone comes across the issue they can use this code.


As dataFieldByName has been deprecated in 3.0

I suggest you use the Extension api and build a quick extension for updateEditForm rather than duplicate the function from ModelAdmin.

class YourExtension extends Extension
    function updateEditForm(&$form)