Jump to:

5542 Posts in 1739 Topics by 1225 members

Customising the CMS

SilverStripe Forums » Customising the CMS » How to add buttons and actions to the CMS

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

Page: 1
Go to End
Author Topic: 278 Views
  • Peavers
    Avatar
    Community Member
    8 Posts

    How to add buttons and actions to the CMS Link to this post

    How do I go about adding a button to the backend of the CMS?

    I can display the button where I want using:

    public function getCMSFields()
    {
    $fields = parent::getCMSFields();

    $fields->addFieldsToTab("Root.ButtonTest", array(
    FormAction::create('doAction', 'Action button')
    )
    );

    return $fields;
    }

    public function doAction()
    {
    //Do something
    }

    However, doAction does nothing when the button is clicked.

    I've seen one example of how to put a button on the main action bar (Next to save/publish) but thats not what I'm trying to do.

    Looking at the only documentation page I can find, do I need to do something within

    public function getCMSActions()
    {
    $actions = parent::getCMSActions();
    //Something here?
    }

    I can't find any clear documentation on how to handle the button action.

    Note: Same question on SO if you want the rep https://stackoverflow.com/questions/23353998/adding-button-to-silverstripe-cms

  • Peavers
    Avatar
    Community Member
    8 Posts

    Re: How to add buttons and actions to the CMS Link to this post

    Core framework needs some work if its so complicated to add a simple button and action that nobody has a clue how to do it eh?

  • camfindlay
    Avatar
    Forum Moderator
    148 Posts

    Re: How to add buttons and actions to the CMS Link to this post

    Can you perhaps provide some more insight into the outcome you are trying to get here?

    What are you building?, where do you want this button to appear and what do you want to happen when it is clicked? From what I know, FormAction is designed to create a button which submits a form, rather than a stand alone button that will just trigger a php method to run.

    Give some context to your question

    278 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.