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