silverstripe-frameworktest/code/recaptcha/RecaptchaTestPage.php
Normann Lou 0a4f22a08f ENHANCEMENT: use FieldList constructor to replace FieldSet constructor for SilverStripe 3
ENHANCEMENT: use FormActioin constructor to replace ImageFormAction constructor for SilverStripe 3
2012-06-30 00:27:32 +12:00

37 lines
705 B
PHP

<?php
class RecaptchaTestPage extends Page {
}
class RecaptchaTestPage_Controller extends Page_Controller {
function Form() {
$fields = new FieldList(
new TextField('MyText')
);
if(class_exists('RecaptchaField')) {
$fields->push(new RecaptchaField('MyRecaptcha'));
} else {
$fields->push(new LiteralField('<p class="message error">RecaptchaField class not found</p>'));
}
$form = new Form(
$this,
'Form',
$fields,
new FieldList(
new FormAction('submit', 'submit')
),
new RequiredFields(array('MyText'))
);
return $form;
}
function submit($data, $form) {
$form->sessionMessage('Hooray!', 'good');
return Director::redirectBack();
}
}