Hi Forum,
i build an simle Contactform with some required fields - it works fine exapt of the CheckboxField - it need to be checked.
How can i do this?
Here my code (part of):
class ContactPage_Controller extends Page_Controller
{
function ContactForm() {
$fields = new FieldSet(
new CheckboxField('Datenschutz', _t('ContactForm.datenschutzklausel'),0),
new TextField('Name', 'Ihr Name*:'),
new EmailField('Email', 'Ihre E-Mail*:'),
new TextareaField('Comments','Nachricht an uns:')
);
$actions = new FieldSet(
new FormAction('SendContactForm', 'Send')
);
$validator = new RequiredFields(array('Name', 'Email', 'Datenschutz'));
return new Form($this, 'ContactForm', $fields, $actions, $validator);
}
function SendContactForm($data, $form) {
$From = $data['Email'];
$To = $this->Mailto;
$Subject = "Mediapool-Login beantragen";
$email = new Email($From, $To, $Subject);
$email->setTemplate('ContactEmail');
$email->populateTemplate($data);
$email->send();
Director::redirect($this->Link("?success=1"));
}
public function Success()
{
return isset($_REQUEST['success']) && $_REQUEST['success'] == "1";
}
}
thanx fpr helping