17488 Posts in 4473 Topics by 1978 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 2463 Views |
-
Form Templates

5 September 2007 at 12:40pm
Hi, I'm trying to set my site up to use a custom template to display the forms, but I'm having some troubles.
I tried overwriting Form.ss, but it seems to be used by the CMS as well, so the admin area was all screwed up by the new form template.
So I put my template into PageForm.ss and changed the page template to use <% include PageForm %> instead of $Form, which works fine (if I put <% control Form %> in it) except that it doesn't work for things like the login page form, since it's rendered with Form.ss but isn't in the Form control.
I could override LoginForm and change it's forTemplate(), but that would have a problem with the <% control Form %> in the template, and I was wondering if there's a tidier and more consistent way. I thought of overriding the Form class, but I can't do that...if I just subclass it or use Object::useCustomClass('Form', 'PageForm'), things like the LoginForm still won't use it, and I'd rather not hack any of SilverStripe's files.Can anyone recommend a nicer way of doing this?
-
Re: Form Templates

2 November 2007 at 5:33am Last edited: 2 November 2007 5:33am
I would be interested in this as well!
-
Re: Form Templates

4 November 2007 at 3:47pm
yeah, useCustomClass is way to global for what you're trying to achieve.
what should your custom template contain that formfields can't handle?
using CompositeFields with setID()/addClassName(), and using LiteralFields for any raw HTML needed can get you a long way towards customsing forms.
if you need a different rendering of a specificl FormField, subclass it and change its Field() or FieldHolder() method.
i don't think there's an easy way to circumvent the <% control Fields %> in a custom template, if thats what you're trying to achieve.we've got a a documentation request outstanding for this kind of customizing: http://open.silverstripe.com/ticket/1540
| 2463 Views | ||
|
Page:
1
|
Go to Top |



