Hi!
What i like to know is: How is it possible to create custom forms?
I like to display a custom form, but it seems that the form attributes wouldn't be parsed...
So, here is my setup:
1. I have my custom Page (KMForm_Page) / PageController (KMFormPage_Controller)
The Controller looks like this:
class KMFormPage_Controller extends Page_Controller
{
function KMForm()
{
return new KMForm($this,'KMForm');
}
}
2. I do of course have a custom Form (KMForm) as used above:
class KMForm extends Form
{
function __construct($controller, $name)
{
$fields = new FieldSet(
new EmailField('email', 'E-Mail-Adresse'),
new TextField('telefon', 'Telefonnummer')
);
$actions = new FieldSet(
new FormAction('submit', 'Absenden')
);
$requiredFields = new RequiredFields('email');
parent::__construct($controller, $name, $fields, $actions, $requiredFields);
}
function forTemplate()
{
// Erwartet Template mit Namen 'KMForm'
return $this->renderWith(array(
$this->class,
'Form'
));
}
function submit($data, $form)
{
print_r($data);
}
}
3. I have a appropriate Template KMForm.ss:
<form $FormAttributes>
<% if Message %>
<p id="{$FormName}_error" class="message $MessageType">$Message</p>
<% else %>
<p id="{$FormName}_error" class="message $MessageType" style="display: none;"></p>
<% end_if %>
<fieldset>
<div id="email" class="field email">
<label for="$Form_email">E-Mail-Adresse</label>
$dataFieldByName(email)
</div>
<div id="telefonnummer" class="field telefon">
<label for="$FormName_telefon">Telefonnummer</label>
$dataFieldByName(telefon)
</div>
$dataFieldByName(SecurityID)
</fieldset>
<% if Actions %>
<div class="Actions">
<% control Actions %>
$Field
<% end_control %>
</div>
<% end_if %>
</form>
Site displays, but:
- The Rendering of the Variables $FormAttributes, $FormName, $Form_email etc. doesn't happen at all
- site displays only the non-dynamic items of KMForm.ss
So, as usual the failure sits in front of the PC...
Any hints, what i'm doing wrong?
Thanks for your time!