2010-10-08 05:06:37 +02:00
|
|
|
<?php
|
|
|
|
class RecaptchaTestPage extends Page {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
class RecaptchaTestPage_Controller extends Page_Controller {
|
|
|
|
|
|
|
|
function Form() {
|
2012-06-29 14:27:32 +02:00
|
|
|
$fields = new FieldList(
|
2010-10-08 05:06:37 +02:00
|
|
|
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,
|
2012-06-29 14:27:32 +02:00
|
|
|
new FieldList(
|
2010-10-08 05:06:37 +02:00
|
|
|
new FormAction('submit', 'submit')
|
|
|
|
),
|
|
|
|
new RequiredFields(array('MyText'))
|
|
|
|
);
|
|
|
|
|
|
|
|
return $form;
|
|
|
|
}
|
|
|
|
|
|
|
|
function submit($data, $form) {
|
|
|
|
$form->sessionMessage('Hooray!', 'good');
|
|
|
|
|
|
|
|
return Director::redirectBack();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|