Jump to:

1999 Posts in 1421 Topics by 613 members

Form Questions

SilverStripe Forums » Form Questions » Adding a second form to the Login Page

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

Page: 1
Go to End
Author Topic: 1220 Views
  • Dann
    Avatar
    Community Member
    4 Posts

    Adding a second form to the Login Page Link to this post

    Hi There,

    I've been trying to find a solution to this today without much luck.

    I want to display a Member Registration Form next to the User Login Form. So if the user doesn't have an account they can just create one on the same page. I'm considering solving it this way - http://www.silverstripe.org/archive/show/3158?start=8#post178888

    How would you go about doing this?

  • simon_w
    Avatar
    Forum Moderator
    471 Posts

    Re: Adding a second form to the Login Page Link to this post

    I would add the register form to my Page_Controller class (say as function RegisterForm), then create a Security_login.ss template in my Layout directory that call both $Form and $RegisterForm

  • Dann
    Avatar
    Community Member
    4 Posts

    Re: Adding a second form to the Login Page Link to this post

    Ahh I see.

    I was trying to extend the LoginForm class. I didn't think to add it to the Page_controller instead. IT should be easy then to just update the template with the two forms. That sounds like a hell of a lot easier way of doing it. I'll try it out on Monday.

    Cheers!

  • Dann
    Avatar
    Community Member
    4 Posts

    Re: Adding a second form to the Login Page Link to this post

    I've added the form now to the Page Controller and it's displaying in the template but when I submit I get this error message.

    The action 'RegistrationForm' does not exist in class Security

    Does anybody know how I can add this action to the Security class?. I don't really want to change the core class if I can avoid that.

  • Dann
    Avatar
    Community Member
    4 Posts

    Re: Adding a second form to the Login Page Link to this post

    This was not as easy as I had hoped.

    Overriding Security.php's $allowed_actions array worked for the Registration form but then failed for all over actions performed by $LoginForm such as "Logging In" and "Logging Out". It wasn't obvious where these are being set.

    To solve this issue I eventually created a RegistrationPage class with the form and included a non-custom $LoginForm into the template.

    I then set a default login destination in the config like this.

    Security::set_default_login_dest('my-profile');

    I then fixed up the Securitty.ss template to show a message when logged in / logged out as the default logout action is still to redirect to this template.

    1220 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.