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

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

$LoginForm in SS3.x

Go to End

6 Posts   2214 Views


Community Member, 146 Posts

7 May 2013 at 6:50am

Hi there, I have a short question ragarding the $LoginForm Variable within the Template of SS3.x

On 2.4.x I was able, to set this Variable somewhere within the Template and add the "LoginForm" to the allowed_actions within Page_Controller (Page.php).
The Loginform then appeared on every Page, that wass including the Template with the Variable.
When Using the Loginform and submitting some wrong Data from anywhere else other than /Security/login, I get automatically rediected to /Security/login, which then shows the LoginForm pre populated with my wrong credentials and the correct Error Message.
Instead, when I enter correct credentials from any Page, I get logged in and stay on this Page.

This is a very nice behaviour, which seems to be gone (or changed) on SS3.x

On SS3.x for my Test, I have put the $LoginForm Variable under $Content.
Now (on a plain SS3.x installation) I open for example the "about-us" Page and fill the LoginForm with the correct credentials. Then I got logged in and am still on the about-us Page.
When I try to use some wrong credentials, I do not get directed to /Security/login (like in SS2.4.x), instead I get directed to "Page not Found".
Similar Problem appears, when pressing the "Login as someone else" Button. Then I only see a blank Page (with the following URL http://ss30.test2.local/page-not-found/LoginForm for example).

Anyone any Idea, how to reimplement the previous feature from SS2.4.x? Or was this removed because of some Security Issues?




Community Member, 22 Posts

9 April 2015 at 11:41am

Did you solve this? I'm having the same issues... driving me nuts and happy to pay for some help/advice


Forum Moderator, 224 Posts

10 April 2015 at 1:09pm

Edited: 10/04/2015 1:28pm


Maybe you could add the following to your Page_Controller:

function MyLoginLink() {
  return "/Security/login/?BackURL=".urlencode($this->Link());

You can then add $MyLoginLink to your template, or wherever the page_controller is the controller rendering the template.

You will avoid all the issues you describe and you still end up with similar functionality - if I understood you correctly that is ;-)



Community Member, 216 Posts

29 July 2016 at 2:50pm

Looking to do this sort of thing too... this would be a silly question if I was a 'Programmer' (I'm not) so please excuse my ignorance BUT:
Where IS the 'Page_Controller' in SS 3??


Forum Moderator, 1899 Posts

29 July 2016 at 7:23pm

@mhdesign if you don't understand that concept I'd adivse they are excellent


Community Member, 216 Posts

29 July 2016 at 9:21pm

Thanks @swaiba, I have had a quick look at these -- haven't found this information yet...