-
-
Save hailwood/672f30ea89dc984b8667 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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