Jump to:

5453 Posts in 1674 Topics by 1198 members

Customising the CMS

SilverStripe Forums » Customising the CMS » SS3: Adding custom action to grid field item form

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

Page: 1
Go to End
Author Topic: 1349 Views
  • tomtom
    Avatar
    Community Member
    1 Post

    SS3: Adding custom action to grid field item form Link to this 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

  • Reflektera
    Avatar
    49 Posts

    Re: SS3: Adding custom action to grid field item form Link to this post

    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?

  • AlphaCactus
    Avatar
    Community Member
    11 Posts

    Re: SS3: Adding custom action to grid field item form Link to this post

    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.

  • justin456
    Avatar
    Community Member
    9 Posts

    Re: SS3: Adding custom action to grid field item form Link to this post

    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.

  • AlphaCactus
    Avatar
    Community Member
    11 Posts

    Re: SS3: Adding custom action to grid field item form Link to this post

    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.

  • lx
    Avatar
    Community Member
    81 Posts

    Re: SS3: Adding custom action to grid field item form Link to this post

    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

  • openbees
    Avatar
    Community Member
    2 Posts

    Re: SS3: Adding custom action to grid field item form Link to this post

    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.

    1349 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.