Jump to:

23459 Posts in 18906 Topics by 2877 members

General Questions

SilverStripe Forums » General Questions » $Loginform Flexiblity

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

Page: 1
Go to End
Author Topic: 1307 Views
  • TerryMiddleton
    Avatar
    Community Member
    108 Posts

    $Loginform Flexiblity Link to this post

    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

  • banal
    Avatar
    Community Member
    901 Posts

    Re: $Loginform Flexiblity Link to this post

    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

  • TerryMiddleton
    Avatar
    Community Member
    108 Posts

    Re: $Loginform Flexiblity Link to this post

    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

  • banal
    Avatar
    Community Member
    901 Posts

    Re: $Loginform Flexiblity Link to this post

    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

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