Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@hailwood
Created August 25, 2014 11:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hailwood/672f30ea89dc984b8667 to your computer and use it in GitHub Desktop.
Save hailwood/672f30ea89dc984b8667 to your computer and use it in GitHub Desktop.
<?php
class ContactPage extends UserDefinedForm {
/**
* @var string
*/
private static $description = 'Adds a contact page.';
/**
* @var string Required Identifier
*/
private static $required_identifier = null;
/**
* @var array Fields on the user defined form page.
*/
private static $db = array(
"SubmitButtonText" => "Varchar",
"ClearButtonText" => "Varchar",
"OnCompleteMessage" => "HTMLText",
"ShowClearButton" => "Boolean",
'DisableSaveSubmissions' => 'Boolean',
'EnableLiveValidation' => 'Boolean',
'HideFieldLabels' => 'Boolean',
'DisableAuthenicatedFinishAction' => 'Boolean',
'DisableCsrfSecurityToken' => 'Boolean',
'ContactEmail' => 'Varchar',
'ContactPhone' => 'Varchar',
'ContactWrite' => 'Varchar'
);
/**
* @var array Default values of variables when this page is created
*/
private static $defaults = array(
'Content' => '$UserDefinedForm',
'DisableSaveSubmissions' => 0,
'OnCompleteMessage' => '<p>Thanks, we\'ve received your submission.</p>'
);
/**
* @var array
*/
private static $has_many = array(
"Fields" => "EditableFormField",
"Submissions" => "SubmittedForm",
"EmailRecipients" => "UserDefinedForm_EmailRecipient"
);
public function getCMSFields() {
// call updateCMSFields after userforms
SiteTree::disableCMSFieldsExtensions();
$fields = parent::getCMSFields();
SiteTree::enableCMSFieldsExtensions();
$contactEmailField = TextField::create('ContactEmail', 'Contact Email Text');
$contactPhoneField = TextField::create('ContactPhone', 'Contact Phone Text');
$contactWriteField = TextField::create('ContactWrite', 'Contact Address Text');
$fields->addFieldToTab('Root.Main', $contactEmailField, 'Content');
$fields->addFieldToTab('Root.Main', $contactPhoneField, 'Content');
$fields->addFieldToTab('Root.Main', $contactWriteField, 'Content');
return $fields;
}
}
class ContactPageController extends UserDefinedForm_Controller {
private static $allowed_actions = array(
'index',
'ping',
'Form',
'finished'
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment