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.

Customising the CMS

SS3: Adding custom action to grid field item form


Reply

7 Posts   1719 Views

Avatar
tomtom

14 August 2012 at 7:29am Community Member, 1 Post

I'm trying to add a custom action to the edit form of items in a gridfield.

I have tried using getCMSActions() on the displayed data object without any luck. It seems that it is not calling that function when its generating the cms page.

I have also tried adding the custom action to the gridfield but with no success either. I'm fairly new to silverstripe and any help would be appreciated.

Thanks

Avatar
Reflektera

26 September 2012 at 9:24am 49 Posts

Any luck with this? I'm upgrading a site from 2.4 and this getCMSActions-thing just don't seem to get called. Can't see that I have changed anything that should interfere with it.

Docs said that getCMSActions() "...needs to be overloaded by solid dataobject...". Exactly what does that mean?

Avatar
AlphaCactus

11 December 2012 at 12:11pm Community Member, 11 Posts

You might take a look at [url]https://github.com/silverstripe/sapphire/pull/526#issuecomment-9468294[/url]. You might have to jump around the last comments a bit to figure it out, at least I did because it isn't a nice clean tutorial.

Avatar
justin456

12 December 2012 at 3:54am Community Member, 9 Posts

Thanks for posting about this. I think it's pretty closely related to what I'm trying to do:

http://www.silverstripe.org/customising-the-cms/show/21647

I'm still somewhat hazy about this, but I think in general extensions are being invoked in 3.0 by calling Object::add_extension() rather than trying to directly extend a core SS php class. So instead of overloading getCMSActions() in a child class, somehow you have to define updateCMSActions(FieldList $actions) in your extension class, which ends up being called by the base class' getCMSActions() from core SilverStripe to incorporate the extra actions you have defined.

But don't take my word on anything yet: I'm still trying to figure this out.

Avatar
AlphaCactus

12 December 2012 at 1:54pm Community Member, 11 Posts

If you do get it figured out, please post an example. There are definitely mysteries to low level stuff in the CMS for me.
In my case I specifically want to have the actions happen in ModelAdmin and it appears that ModelAdmin doesn't call getCMSActions when it is generated its ItemEditForm so I don't know how external code could inject actions.

My solution, derived from that link I posted, is working for me, but for sure that doesn't mean it is the best one.

Avatar
lx

13 December 2012 at 1:09am Community Member, 83 Posts

Concerning the question of how to add a custom action to the grid, you can look at my little flags module.
https://github.com/lx-berlin/silverstripe-flags

You can see in the screenshot that some additional icons are added.

I had no time yet to find out, why they are to big.
It would look nicer if they are a little bit smaller.

For bugfixes and suggestions of the flags module please use this thread
http://www.silverstripe.org/all-other-modules/show/21380

Avatar
openbees

12 May 2013 at 12:50am Community Member, 2 Posts

I had a hard time finding this. Finally I could do this with this code [url]http://www.sspaste.com/paste/show/518e3dc335c85[/url]

Its still not working in has_many relations. Please update this post if someone can find a way to do this in relation.