src/Forms/GridField/GridFieldDetailForm_ItemRequest.php
protected function getFormActions()
    {
        $actions = new FieldList();

        if ($this->record->ID !== 0) { // existing record
            if ($this->record->canEdit()) {
                $actions->push(FormAction::create('doSave', _t('SilverStripe\\Forms\\GridField\\GridFieldDetailForm.Save', 'Save'))
                    ->setUseButtonTag(true)
                    ->addExtraClass('btn-primary font-icon-save'));
            }

            if ($this->record->canDelete()) {
                $actions->push(FormAction::create('doDelete', _t('SilverStripe\\Forms\\GridField\\GridFieldDetailForm.Delete', 'Delete'))
                    ->setUseButtonTag(true)
                    ->addExtraClass('btn-outline-danger btn-hide-outline font-icon-trash-bin action--delete'));
            }

            $gridState = $this->getRequest()->requestVar('gridState');
            $this->gridField->getState(false)->setValue($gridState);
            $actions->push(HiddenField::create('gridState', null, $gridState));

            $actions->push($this->getRightGroupField());
        } else { // adding new record
            //Change the Save label to 'Create'
            $actions->push(FormAction::create('doSave', _t('SilverStripe\\Forms\\GridField\\GridFieldDetailForm.Create', 'Create'))
                ->setUseButtonTag(true)
                ->addExtraClass('btn-primary font-icon-plus-thin'));

            // Add a Cancel link which is a button-like link and link back to one level up.
            $crumbs = $this->Breadcrumbs();
            if ($crumbs && $crumbs->count() >= 2) {
                $oneLevelUp = $crumbs->offsetGet($crumbs->count() - 2);
                $text = sprintf(
                    "<a class=\"%s\" href=\"%s\">%s</a>",
                    "crumb btn btn-secondary cms-panel-link", // CSS classes
                    $oneLevelUp->Link, // url
                    _t('SilverStripe\\Forms\\GridField\\GridFieldDetailForm.CancelBtn', 'Cancel') // label
                );
                $actions->push(new LiteralField('cancelbutton', $text));
            }
        }

        $this->extend('updateFormActions', $actions);

        return $actions;
    }
protected function getFormActions()
    {
        $actions = new FieldList();

        if ($this->record->ID !== 0) { // existing record
            if ($this->record->canEdit()) {
                $actions->push(FormAction::create('doSave', _t('SilverStripe\\Forms\\GridField\\GridFieldDetailForm.Save', 'Save'))
                    ->setUseButtonTag(true)
                    ->addExtraClass('btn-primary font-icon-save'));
            }

            if ($this->record->canDelete()) {
                $actions->push(FormAction::create('doDelete', _t('SilverStripe\\Forms\\GridField\\GridFieldDetailForm.Delete', 'Delete'))
                    ->setUseButtonTag(true)
                    ->addExtraClass('btn-outline-danger btn-hide-outline font-icon-trash-bin action--delete'));
            }

            $gridState = $this->getRequest()->requestVar('gridState');
            $this->gridField->getState(false)->setValue($gridState);
            $actions->push(HiddenField::create('gridState', null, $gridState));

            $actions->push($this->getRightGroupField());
        } else { // adding new record
            //Change the Save label to 'Create'
            $actions->push(FormAction::create('doSave', _t('SilverStripe\\Forms\\GridField\\GridFieldDetailForm.Create', 'Create'))
                ->setUseButtonTag(true)
                ->addExtraClass('btn-primary font-icon-plus-thin'));

            // Add a Cancel link which is a button-like link and link back to one level up.
            $crumbs = $this->Breadcrumbs();
            if ($crumbs && $crumbs->count() >= 2) {
                $oneLevelUp = $crumbs->offsetGet($crumbs->count() - 2);
                $text = sprintf(
                    "<a class=\"%s\" href=\"%s\">%s</a>",
                    "crumb btn btn-secondary cms-panel-link", // CSS classes
                    $oneLevelUp->Link, // url
                    _t('SilverStripe\\Forms\\GridField\\GridFieldDetailForm.CancelBtn', 'Cancel') // label
                );
                $actions->push(new LiteralField('cancelbutton', $text));
            }
        }

        $this->extend('updateFormActions', $actions);

        return $actions;
    }
protected function getFormActions ( ) { $ actions = new FieldList ( ) ; if ( $ this -> record -> ID !== 0 ) { // existing record if ( $ this -> record -> canEdit ( ) ) { $ actions -> push ( FormAction :: create ( 'doSave' , _t ( 'SilverStripe\\Forms\\GridField\\GridFieldDetailForm.Save' , 'Save' ) ) -> setUseButtonTag ( true ) -> addExtraClass ( 'btn-primary font-icon-save' ) ) ; } if ( $ this -> record -> canDelete ( ) ) { $ actions -> push ( FormAction :: create ( 'doDelete' , _t ( 'SilverStripe\\Forms\\GridField\\GridFieldDetailForm.Delete' , 'Delete' ) ) -> setUseButtonTag ( true ) -> addExtraClass ( 'btn-outline-danger btn-hide-outline font-icon-trash-bin action--delete' ) ) ; } $ gridState = $ this -> getRequest ( ) -> requestVar ( 'gridState' ) ; $ this -> gridField -> getState ( false ) -> setValue ( $ gridState ) ; $ actions -> push ( HiddenField :: create ( 'gridState' , null , $ gridState ) ) ; $ actions -> push ( $ this -> getRightGroupField ( ) ) ; } else { // adding new record //Change the Save label to 'Create' $ actions -> push ( FormAction :: create ( 'doSave' , _t ( 'SilverStripe\\Forms\\GridField\\GridFieldDetailForm.Create' , 'Create' ) ) -> setUseButtonTag ( true ) -> addExtraClass ( 'btn-primary font-icon-plus-thin' ) ) ; // Add a Cancel link which is a button-like link and link back to one level up. $ crumbs = $ this -> Breadcrumbs ( ) ; if ( $ crumbs && $ crumbs -> count ( ) >= 2 ) { $ oneLevelUp = $ crumbs -> offsetGet ( $ crumbs -> count ( ) - 2 ) ; $ text = sprintf ( "<a class=\"%s\" href=\"%s\">%s</a>" , "crumb btn btn-secondary cms-panel-link" , // CSS classes $ oneLevelUp -> Link , // url _t ( 'SilverStripe\\Forms\\GridField\\GridFieldDetailForm.CancelBtn' , 'Cancel' ) // label ) ; $ actions -> push ( new LiteralField ( 'cancelbutton' , $ text ) ) ; } } $ this -> extend ( 'updateFormActions' , $ actions ) ; return $ actions ; }
Build the set of form field actions for this DataObject

@return FieldList
Build the set of form field actions for this DataObject