Hi! I'm a newbie in silverstripe and I would just like to ask if how can i add an attribute in a form? For example i want to add onsubmit=''return false;" and class="myClass". Here is the function that I'm using:
public function NewsletterForm() {
$fields = new FieldSet(
new EmailField('Email','')
);
$actions = new FieldSet(
new FormAction('NewsletterSubmit', 'Ok!')
);
$validator = new RequiredFields('Email','onsubmit');
return new Form($this, 'NewsletterSubmit', $fields, $actions,$validator);
}
/**
* Inserts a submitted email to database
* @param <type> $form
*/
public function NewsletterSubmit($form) {
$newsletter = new Newsletter();
$newsletter->Email=$_POST['Email'];
$newsletter->write();
return Director::redirectBack();
//Director::redirect(Director::currentURLSegment()."?msg=Thank+you+for+signing+up!");
}
Any help will be much appreciated. Thanks!