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.

Form Questions

Customise html output of form


Reply

2 Posts   1770 Views

Avatar
gethyn1

8 September 2009 at 3:34am Community Member, 1 Post

I currently have a contact form displaying the following mark up:

<form>
<fieldset>
<legend></legend>

<div id="Name" class="field text ">
<label class="left" for="Form_ContactForm_Name">Name*</label>
<div class="middleColumn">
<input type="text" class="text" id="Form_ContactForm_Name" name="Name" value="" />
</div>
</div>

<div id="Email" class="field email ">
<label class="left" for="Form_ContactForm_Email">Email*</label>
<div class="middleColumn">
<input type="text" class="text" id="Form_ContactForm_Email" name="Email" value="" />
</div>
</div>
      
<div id="Comments" class="field textarea ">
<label class="left" for="Form_ContactForm_Comments">Comments*</label>
<div class="middleColumn">
<textarea id="Form_ContactForm_Comments" name="Comments" rows="5" cols="20"></textarea>
</div>
</div>

<input class="hidden" type="hidden" id="Form_ContactForm_SecurityID" name="SecurityID" value="760995074" />
</fieldset>
<input class="action" id="Form_ContactForm_action_SendContactForm" type="submit" name="action_SendContactForm" value="Send" title="Send" />
</form>

I would like to strip out the unnecessary divs and classes so that the markup looks more like this:

<form>
<fieldset>
<legend></legend>

<label for="Form_ContactForm_Name">Name*</label>
<input type="text" id="Form_ContactForm_Name" name="Name" value="" />

<label for="Form_ContactForm_Email">Email*</label>
<input type="text" id="Form_ContactForm_Email" name="Email" value="" />
      
<label for="Form_ContactForm_Comments">Comments*</label>
<textarea id="Form_ContactForm_Comments" rows="5" cols="20"></textarea>

<input class="hidden" type="hidden" id="Form_ContactForm_SecurityID" name="SecurityID" value="760995074" />
</fieldset>
<input class="action" id="Form_ContactForm_action_SendContactForm" type="submit" name="action_SendContactForm" value="Send" title="Send" />
</form>

I managed to edit some of the html output in sapphire/templates/includes/Form.ss but can't locate where the rest of the mark up is being defined.

Any help would be appreciated, thanks..

Avatar
Ingo

13 September 2009 at 5:59pm Forum Moderator, 801 Posts

Have a look at http://doc.silverstripe.com/doku.php?id=form#using_a_custom_template