Jump to:

2011 Posts in 1436 Topics by 620 members

Form Questions

SilverStripe Forums » Form Questions » Customising member login form

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

Page: 1
Go to End
Author Topic: 1622 Views
  • Scorpiankh
    Community Member
    60 Posts

    Customising member login form Link to this post

    Hi. I'm trying to find a way to customise the login bit for members-only pages on a website I'm building.
    What I want to do is this:
    - change the 'email' label on login to 'username'
    - remove the 'lost password' link
    - add a link for 'change password' that gets displayed once a user is logged in.

    I tried changing the 'email' label to 'username' in sapphire/security/MemberLoginForm.php but all I managed to do was make the login form not work at all.
    As far as I can tell all the code for the things I want to do is in MemberLoginForm.php but I'm not sure which bits exactly to edit, I'm still pretty new to php, still getting the hang of it.
    Can anyone tell me how to go about making the login form work how i want it?


  • rob.s
    Community Member
    78 Posts

    Re: Customising member login form Link to this post


    perhaps the following helps.

    create a custom class that extends MemberLoginForm :

    For example:

    class MyCustomLoginForm extends MemberLoginForm {

    public function __construct($controller, $name, $fields = null, $actions = null, $checkCurrentUser = true) {

    $fields = new FieldSet(
    new HiddenField("AuthenticationMethod", null, $this->authenticator_class, $this),
    //Regardless of what the unique identifer field is (usually 'Email'), it will be held in the 'Email' value, below:
    new TextField("Email", $label, Session::get('SessionForms.MemberLoginForm.Email'), null, $this),
    new PasswordField("Password", _t('Member.PASSWORD', 'Password'))
    if(Security::$autologin_enabled) {
    $fields->push(new CheckboxField(
    _t('Member.REMEMBERME', "Remember me next time?")

    parent::__construct($controller, $name, $fields, $actions, $checkCurrentUser);


    you can add custom fields to the fieldset .....

    then put into your _config.php

    Object::useCustomClass('MemberLoginForm', 'MyCustomLoginForm');

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.