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

Custom CMS page: pass Message to Form & call statusMessage from PHP [PARTIAL SOLVE]


Go to End


1526 Views

Avatar
DesignCollective

Community Member, 66 Posts

23 November 2015 at 8:18am

Edited: 23/11/2015 8:25am

Hello, I have a custom CMS page, with a CMSForm - the action is saving and processing nicely. I'm pretty excited about that (first time I'm extending a CMS page, so - yay!)

Now.. after saving, I'd like to show a success notice in the CMS. So:

* Can someone show me how to call a "statusMessage" (JS) from the PHP. Is it a return, an echo... I'm a bit confused about how those things tie together.

* How do I pass a message into a form from the form PHP callback?
I tried:

public function doSaveSettings($data, Form $form) {
   $form->setMessage("This is cool","good");
   $this->redirectBack();
}

But it's not passing. I'm feeling funny doing all kinds of crazy thigs with SS through these years but I still can't do this :) Thank you everyone!

EDIT:
This 2nd part, because of the redirect, one needs to set a sessionMessage on the form, so $form->sessionMessage($message, $type).