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.

General Questions

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

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

$Loginform Flexiblity


4 Posts   1318 Views


2 April 2009 at 3:59am Community Member, 108 Posts

I'm using the $Loginform and it works perfect.

I want to change the layout and have control of the fields,labels etc...

How can I do this?

For example, I don't need the labels and need to shrink to field (inputs) a little, plus I need to layout the login form a little differently.

How can I do this?



2 April 2009 at 7:13pm (Last edited: 2 April 2009 7:15pm), Community Member, 901 Posts

Hi Terry

You could simply achieve that using CSS. Even removing the unwanted labels can be as easy as:

#MemberLoginForm_LoginForm label { display:none; }

If you don't want the labels showing up in your code at all, you'll have to create a custom template. That's quite easy though. Best you copy from sapphire/templates/includes to mysite/templates/includes and apply changes on the file in your includes directory.
That way, the template parser will use your custom and you're not modifying any core files (in case of an update you won't have to worry about overwriting files the sapphire folder).



2 April 2009 at 11:28pm Community Member, 108 Posts


Thank you for this. I will try this both ways.

I don't yet understand how the file works. I want to.

I see it and understand that if offers great flexability, but I'll need to make sure I understand the impact of changing this file.

I'm new at using SilverStripe, but WOW what a great system.

Do you know of any place where I can gain understanding of how this all works. Each day the more I look at it and work with it I get better and better, but there is still a disconnect on how to achieve certain things.

I'm left with one thing: There isn't much you couldn't achieve with SilverStripe and Sapphire

What are your thoughts?



3 April 2009 at 2:39am (Last edited: 3 April 2009 2:43am), Community Member, 901 Posts

Hi Terry

I just had another look at the template and apparently, you can't change the labels there. I'm sorry for misguiding you. It is slightly more complicated. If I get this right, it works like so:
The label text is being set in the FormField constructors. To see how the LoginForm is being built, have a look at the MemberLoginForm.php class (to be found sapphire/security).
Each (visible) field is being rendered using the FormField->FieldHolder method (sapphire/forms/FormField.php). The generated output is then being injected in the template (<% control Fields %>).
There's also a Template (in sapphire/templates) but I don't know when this one will be used. It seems to create the same output as the FieldHolder method does.

To cut a long story short: I guess it would be a lot easier to go the CSS route, instead of creating custom FormField classes and templates.
To wrap the login form in a custom html element or to add a title or anything, you can still modify The template is valid for all Forms. To just modify the output of the MemberLoginForm you could create a in mysite/templates/includes that will be used exclusively to render the MemberLoginForm.

Yeah, SilverStripe is a great system. But I'm far from being an expert. Learning new stuff every day.
After the tutorials, these docu pages helped me a lot to understand the underlying mechanisms of SilverStripe (and reading through the code of course):