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.

Template Questions /

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

What is the purpose/function of $Form in the template?


Go to End


4 Posts   1388 Views

Avatar
vwd

Community Member, 166 Posts

4 April 2011 at 5:02pm

Hi,

I'm trying to create a simplified template (based on the tutorial) and trying to remove unnecessary code.

I notice that the code

$Form
exists in the Tutorial template.

What does it do? From what I can tell so far, it provides the admin login form code. Does it do anything else? Is its functionality documented anywhere?

Thanks very much.

VWD.

Avatar
swaiba

Forum Moderator, 1899 Posts

6 April 2011 at 8:19am

When you have a

function Form() 

in your controller - it shows it, when you don't you'll never know it was there... for example enable comments on a page and the $Form will be used.

Avatar
vwd

Community Member, 166 Posts

6 April 2011 at 10:13am

OK - Thanks for that Swaiba.

So it seems like something important, and that I have to keep in the template? (Although I'm not using comments in this instance)

Also where does the admin login form code reside?

Thanks Swaiba.

VWD.

Avatar
Willr

Forum Moderator, 5523 Posts

6 April 2011 at 8:15pm

So it seems like something important, and that I have to keep in the template? (Although I'm not using comments in this instance

You need it at least on Page.ss (or Security.ss) as that is what LoginForm renders into. UserForms (if you use it) will also use $Form.