Created
December 1, 2021 03:26
-
-
Save jkersu/f7ae8bdacb7a7178662ca2701c355167 to your computer and use it in GitHub Desktop.
Add a button to a Silverstripe Page in the CMS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Add an extension to SilverStripe\Admin\LeftAndMain | |
class LeftAndMainExtension extends Extension | |
{ | |
public function someFancyAction($data, $form) | |
{ | |
// do some fancy stuff | |
} | |
} | |
// Add to your PageType class where you want the button | |
public function getCMSActions() | |
{ | |
$actions = parent::getCMSActions(); | |
$buttons = $actions->fieldByName('MajorActions'); | |
$buttons->push($newFields = FormAction::create('someFancyAction', 'Do Action')); | |
$newFields ->addExtraClass('btn-outline-primary font-icon-tick') | |
->setUseButtonTag(true); | |
return $actions; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Great example also!!! love it.