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

Remove Preview Button


Go to End


3 Posts   1494 Views

Avatar
suntrop

Community Member, 141 Posts

4 February 2013 at 6:12am

I want to remove (or at least hide) the Preview button on some of my pagetypes, because those pagetypes are only viewable within their parent pages. Thus the preview will fail and looks terrible at the front-end :-)

Found this, but doesn't worked:

public function EditForm() {
		$form = parent::EditForm();
		$actions = $form->Actions();
		$actions->removeByName('Preview'); // remove save button from form
		return $form;
	}
	function getCMSActions(){
	    $actions = parent::getCMSActions();
	    $Action = new FormAction(
	           "doAction",
	           "Do something different"
	        );
	    $actions->push($Action);
	    $actions->removeByName('Save');
	    $actions->removeByName('Unpublish');
	    $actions->removeByName('Publish');
	    $actions->removeByName('Delete');
	    $actions->removeByName('Preview');
	    return $actions;
	}

Avatar
Spambanjo

Community Member, 24 Posts

21 November 2013 at 12:16am

I also need a solution to this problem, did you ever find anything?

I'm amazed there isn't a simple $allow_preview static for disabling it all together on certain page types.

Avatar
suntrop

Community Member, 141 Posts

22 November 2013 at 5:07am

No, unfortunately I found nothing about it, but I stopped working with SS completely :-)