push(new RecaptchaField('MyRecaptcha')); } else { $fields->push(new LiteralField('
')); } $form = new Form( $this, 'Form', $fields, new FieldList( new FormAction('submit', 'submit') ), new RequiredFields(array('MyText')) ); return $form; } public function submit($data, $form) { $form->sessionMessage('Hooray!', 'good'); return Director::redirectBack(); } }