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.

All other Modules /

Discuss all other Modules here.

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

User Defined Form - styling form fields


Reply


2 Posts   3085 Views

Avatar
BigChris

Community Member, 63 Posts

11 January 2010 at 9:05am

Hello,

I have a contact us page and using it with the User Defined Form module to create a contact form. Its setup as another template page called UserDefinedForm.ss and all is working fine.

But, I would like to customise the styling of the Form by adding css classes to it. To use the form on the template I add the silverstripe variable $Form.

Is it possible to create another template for $Form so that I can over ride the default layout and add additional classes?
If so what would I call the template file and where would it go (Inside the include?)

I looked over the Module and the base Silverstripe code but could not figure out away to style the Form.

Any help is greatly appreciated.

Regards
Chris

Avatar
Willr

Forum Moderator, 5513 Posts

11 January 2010 at 1:22pm

You're going to have some issues trying to customize the html output of the UDF. If you want to edit the style of the form the best way is to use CSS to get the positioning / style effects. The form fields are fairly well equipped with class's which you can use as styling hooks so even with the existing html you should have enough options to get most form layouts working.

You can customize the form output but it means you're hard coding the form fields so makes using a template on a UDF kinda pointless - http://doc.silverstripe.org/doku.php?id=form&s=form#using_a_custom_template