Login | Forgot password | Register

X

What is OpenID?

OpenID is an Internet-wide identity system that allows you to sign in to many websites with a single account.

With OpenID, your ID becomes a URL (e.g. http://username.myopenid.com/). You can get a free OpenID for example from myopenid.com.

For more information visit the official OpenID site.

Jump to:

17480 Posts in 4474 Topics by 1973 members

Archive

SilverStripe Forums » Archive » Form Templates

Our old forums are still available as a read-only archive.

Page: 1
Go to End
Author Topic: Form Templates 1556 Views
  • Nathan Cox
    avatar
    Community Member
    84 posts

    Form Templates Link to this post

    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?

  • lukehumble
    avatar
    17 posts

    Re: Form Templates Link to this post

    I would be interested in this as well!

  • Ingo
    avatar
    Administrator
    508 posts

    Re: Form Templates Link to this post

    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

    1556 Views
Page: 1
Go to Top

Currently Online: JoshuaLewis, NickJacobs

Welcome to our latest member: marcusl

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.