Hi,
I've just chosen to learn SilverStripe by building a quick client site using it. It's been surprisingly painless to learn, except for one thing which I can't work out.
How does setting a Form's Action work? Does it require prototype.js since the action is assigned to the button rather than the form?
I built the below (to subscribe people to a mailchimp database after first creating a unique 'key' for them) by following the wiki and then following a forum post about replacing prototype with jquery.
function MailchimpSubscribeForm() {
// Create fields
$fields = new FieldSet(
new TextField('Name'),
new EmailField('Email')
);
// Create actions
$actions = new FieldSet(
new FormAction('doMailchimpSubscribeForm', 'Subscribe')
);
$validator = new RequiredFields('Name', 'Email');
$form = new Form($this, 'MailchimpSubscribeForm', $fields, $actions, $validator);
$form->loadDataFrom($this->failover);
// set the custom script for this form
Requirements::customScript('
$(document).ready(function() {
...
});
');
return $form->forTemplate();
}
function doMailchimpSubscribeForm($data, $form) {
//create key
...
//attempt to subscribe to list
...
//return response
...
}
When the form is submitted, it goes to /home/MailchimpSubscribeForm and the form is displayed again. The code in doMailchimpSubscribeForm() is never run.
What am I missing here?