Jump to:

3435 Posts in 1026 Topics by 866 members

Template Questions

SilverStripe Forums » Template Questions » Add extra class to forgotten password submit button in form template

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

Page: 1
Go to End
Author Topic: 773 Views
  • george_n
    Avatar
    Community Member
    2 Posts

    Add extra class to forgotten password submit button in form template Link to this post

    Hi, I want to change user forgotten password template and add css class to submit button.

    I know I can overwrite templates with Secutiry.ss and also I can override MemberLoginForm.ss but In template I can not add css class to submit button.

    I know that I can do Field->addExtraClass(className) in controller but first I want to separate view from controller and also If I want to change forgotten password submit button I have to subbclass Security class and change LostPasswordForm method and add in it Field->addExtraClass.

    I can not use css to style the button with current classes

    So is there any easy way to achieve this without subclassing Security class ?

  • george_n
    Avatar
    Community Member
    2 Posts

    Re: Add extra class to forgotten password submit button in form template Link to this post

    Hmm, I have tried to subclass Security class and it does not work. I suppose this is the reason:

    http://www.silverstripe.org/data-model-questions/show/4766

    It looks like adding class to forgotten password button without javascript is not possible.

  • Willr
    Avatar
    Forum Moderator
    5490 Posts

    Re: Add extra class to forgotten password submit button in form template Link to this post

    You don't need to subclass Security but 'MemberLoginForm'.

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

    Then you can customise the login form as you wish in the constructor

    <?php

    class CustomLoginForm extends MemberLoginForm {

    function __construct($controller, $name, $fields = null, $actions = null, $checkCurrentUser = true) {
    parent::__construct($controller, $name, $fields, $actions, $checkCurrentUser);
          
    // .. do your work
    }
    }

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