5121 Posts in 1527 Topics by 1119 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1890 Views |
-
How to customize userform form display

26 June 2010 at 10:44am
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 -
Re: How to customize userform form display

26 June 2010 at 2:48pm
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 |


