Jump to:

5121 Posts in 1527 Topics by 1119 members

Customising the CMS

SilverStripe Forums » Customising the CMS » How to customize userform form display

Moderators: martimiz, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 1890 Views
  • sagelike
    Avatar
    Community Member
    2 Posts

    How to customize userform form display Link to this post

    I'm very new to Silverstripe and I'm trying to figure how to customize the form display for forms created using the userform module.

    At first I though I'd be able to target elements using CSS but unfortunately, userform actually uses standard tags in the html output so that if I change "left" I change all form fields in silverstripe, i.e. The admin login fields and whatever else uses it.

    Here's the output:

    <div id="EditableTextField21" class="field text requiredField"><label class="left" for="Form_Form_EditableTextField21">My Form Field</label><div class="middleColumn"><input type="text" class="text requiredField" id="Form_Form_EditableTextField21" name="EditableTextField21" value="" /></div></div>

    I want to target the <label> tag with CSS so I need to find a way to add custom IDs or classes to the form elements HTML out for each individual form but SS doesn't seem to provide an effective method for doing this.

    What I did in the short term was add these tags around the Field name in the form builder <span id=form>Form Label</span> It worked but the output shows in the delivered email so that solution won't work for long.

    I've looked at the code and googled but haven't been able to figure out where I can customize the code to simply add something like id="myfield" to the output.

    Can anyone offer some advice?

    Thanks in advance
    G

  • Willr
    Avatar
    Forum Moderator
    5208 Posts

    Re: How to customize userform form display Link to this post

    Hi Sagelike,

    One thing you could do is create a UserDefinedForm.ss template (copy content from your Page.ss) and wrap the $Form variable in the template with an ID

    <div id="UserForm">
    $Content
    $Form
    </div>

    Then you could target the UserForm form fields with #UserForm ... {}. I do like the idea of customizing classes on a per form and per form field basis so I have created a ticket for it http://open.silverstripe.org/ticket/5751.

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