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've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Customising the CMS /

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

SS3: Adding custom action to grid field item form


Go to End


7 Posts   7108 Views

Avatar
tomtom

Community Member, 1 Post

14 August 2012 at 7:29am

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

49 Posts

26 September 2012 at 9:24am

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

Community Member, 12 Posts

11 December 2012 at 12:11pm

You might take a look at https://github.com/silverstripe/sapphire/pull/526#issuecomment-9468294. 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

Community Member, 9 Posts

12 December 2012 at 3:54am

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

Community Member, 12 Posts

12 December 2012 at 1:54pm

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

Community Member, 83 Posts

13 December 2012 at 1:09am

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

Community Member, 3 Posts

12 May 2013 at 12:50am

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

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