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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

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

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

$Loginform Flexiblity


Go to End


4 Posts   1931 Views

Avatar
TerryMiddleton

Community Member, 108 Posts

2 April 2009 at 3:59am

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?

Terry

Avatar
bummzack

Community Member, 904 Posts

2 April 2009 at 7:13pm

Edited: 02/04/2009 7:15pm

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 Form.ss 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 Form.ss 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).

HTH

Avatar
TerryMiddleton

Community Member, 108 Posts

2 April 2009 at 11:28pm

Banal,

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

I don't yet understand how the Form.ss 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?

Terry

Avatar
bummzack

Community Member, 904 Posts

3 April 2009 at 2:39am

Edited: 03/04/2009 2:43am

Hi Terry

I just had another look at the Form.ss 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 Form.ss template (<% control Fields %>).
There's also a DefaultFieldHolder.ss 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 Form.ss. The Form.ss template is valid for all Forms. To just modify the output of the MemberLoginForm you could create a MemberLoginForm.ss 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):
http://doc.silverstripe.com/doku.php?id=templates
http://doc.silverstripe.com/doku.php?id=datamodel
http://doc.silverstripe.com/doku.php?id=dataobject
http://doc.silverstripe.com/doku.php?id=objectmodel