Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
SilverStripe Blocks - Block with contact form example
class ContactBlock extends Block {
* Template accessor for the form
public function ContactForm(){
return $this->getController()->ContactForm();
class ContactBlock_Controller extends Block_Controller {
private static $allowed_actions = array(
public function ContactForm(){
$fields = FieldList::create(array(
$actions = FieldList::create(
FormAction::create('submit', 'Send Enquiry')
return Form::create($this, 'ContactForm', $fields, $actions);
public function submit($data, $form){
// process form data as usual
// ...
// redirect
return $this->redirect($this->pageLink() . '?contacted=1');
<div class='$CSSClasses'>

This comment has been minimized.

Copy link

@hohl hohl commented Sep 11, 2016

How do you get the HTTP GET parameter within the controller or the template? Like the ?contacted=1 part?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment