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.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Add contact form to Page

Go to End

4 Posts   1328 Views


Community Member, 349 Posts

10 March 2011 at 1:24pm

How to add translateable fields names to form on somepage.php or in
let say that the fields are simple like subject with Value=$title of page
email and message and also the submit button must be translatable.

i know that i need to use <% _t("Name","Name:") %> in .ss file
but how to use translatable in .php and what lines i need u but in the lang file if i wanna let say translate fieldname "name" from mysite/somepage.php


Community Member, 349 Posts

10 March 2011 at 1:26pm

and also what code i need to use in .php fail that i takes the page tilte and but it into subject of forms email.


Community Member, 349 Posts

10 March 2011 at 2:41pm

Can somone plz help


Forum Moderator, 1391 Posts

11 March 2011 at 1:43am

I'm not quite sure what it is you're aiming at, but maybe this will help some?

If you are building a custom form on your website (and not the UserForms module) using a ContactForm() method in your page controller, adding a translatable label goes the same way as with the CMSfields:

function ContactForm() {

	$fields = new FieldSet(
		new TextField(

If you were to use a custom form template, where you'd indeed define your labels, use <% _t('ContactPage.NAME','Name')) %>. Make sure there is no whitespace after the comma...

Then add the translation to your languagefile xx_XX.php, like

$lang['xx_XX]['MyContactPage']['Name'] = 'translated name';

If you use <% _t('NAME','Name')) %> (without the ContactPage namespace) SilverStripe will automatically use the template name, so for, you'd have to put this in your language file:

$lang['xx_XX]['']['Name'] = 'translated name';

However, this doesn't always work well with nested templates so take care.

(make sure the correct locale is set for your page)

Getting your page title into the subject (still assuming you're using a custom form) You'd do something like this in you 'submit' method:

function doSubmit($postedData, $form){

	$Email = new Email();