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.

Template Questions /

Add extra class to forgotten password submit button in form template


Reply


3 Posts   863 Views

Avatar
george_n

Community Member, 2 Posts

6 December 2012 at 2:54am

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 ?

Avatar
george_n

Community Member, 2 Posts

6 December 2012 at 11:40pm

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.

Avatar
Willr

Forum Moderator, 5513 Posts

8 December 2012 at 4:43pm

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