When I click submit button, just refreshing page. (nothing happened. Validation is not working neither)
What do I need to fix?
I'm using template form (http://doc.silverstripe.org/sapphire/en/topics/forms#using_a_custom_template)
Landing.php
<?php
class Landing_Controller extends Page_Controller {
static $allowed_actions = array(
//'MyForm'
);
public function MyForm(){
return new MyForm($this, 'MyForm');
}
}
?>
MyForm.php
<?php
class MyForm extends Form {
function __construct($controller, $name) {
$fields = new FieldSet(
new TextField('name', 'name', 'first','20')
new EmailField('Email', 'Email address'),
);
$actions = new FieldSet(
new FormAction('sendRequest', 'send request')
);
$validator = new RequiredFields('name', 'Email'');
parent::__construct($controller, $name, $fields, $actions, $validator);
}
function forTemplate() {
return $this->renderWith(array(
$this->class,
'Form'
));
}
public function sendRequest($data, $form) {
//submit code
}
}
?>
MyForm.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>
<table>
<tr><td>name</td><td>$dataFieldByName(name)</td></tr>
<tr><tdemail></td><td>$dataFieldByName(Email)</td></tr>
</table>
$dataFieldByName(SecurityID)
</fieldset>
<% if Actions %>
<div class="Actions">
<% control Actions %>$Field<% end_control %>
</div>
<% end_if %>
</form>