I am building a page with two languages (english and german). For this i am using the translatable module offered on the silverstirpe page (http://addons.silverstripe.org/add-ons/silverstripe/translatable). On regular pages it works just like a charm. The contact form gets created in a controller. By $form->setTemplate i load a custom template for the form, which is located in the template's include subdirectory. In the class file I defined the different TextFields (model part), which I want to use in the form template. Here is the controller:
class MietenPage extends Page {
private static $db = array (
//Form
'ChoosPakage' => 'Varchar',
'FormEventHeadline' => 'Varchar',
'FormNoteHeadline' => 'Varchar',
'FormContactHeadline' => 'Varchar',
'FormAdditionalHeadline' => 'Varchar',
'FormCheckOverlay' => 'Varchar',
'FormCheckCaseDesign' => 'Varchar',
'FormCheckAGB' => 'Varchar',
'FormSubmit' => 'Varchar',
'AGBAlert' => 'Varchar'
);
public function getCMSFields() {
$fields = parent::getCMSFields();
//...
return $fields;
}
}
class MietenPage_Controller extends Page_Controller {
private static $allowed_actions = array('ContactForm');
public function ContactForm() {
$fields = new FieldList(
//...
);
$actions = new FieldList(
new FormAction('submit', 'Anfrage Senden!')
);
$form = new Form($this, 'ContactForm', $fields, $actions);
$form->setTemplate('ContactFormTemplate');
return $form;
}
public function submit($data, $ContactForm) {
$email = new Email();
//...
}
}
n my template i am calling the form using $ContactForm. This works totally fine, including all functionalities.
My Problem is, that I can not access the variables (like headline or submit button text eg. $FormEventHeadline), which hold the text in my custom template - just emptyness is returned. I think it has to do something with scope, but i can not solve this problem.
Thanks in advance ;)