I am creating a custom email form. I want the administrator to be able to change the email address and subject for form submissions. How can I access the values that the admin sets in the tabs for a page?
PHP code
<?php
class ContactForm extends Page {
static $db = array(
'EmailToAddress' => 'Varchar(250)',
'EmailSubject' => 'Varchar(250)'
);
static $has_one = array(
);
function getCMSFields() {
$fields = parent::getCMSFields();
$fields->addFieldToTab("Root.Content.Email", new TextField('EmailToAddress','Email address to send form submissions to)'));
$fields->addFieldToTab("Root.Content.Email", new TextField('EmailSubject','Subject to be used for form submissions'));
return $fields;
}
}
class ContactForm_Controller extends Page_Controller {
function submitForm() {
if(!empty($_POST)) {
mail(_EMAILADDRESS_SET_IN_EMAIL_TAB_, '_SUBJECT_SET_IN_EMAIL_TAB_', 'Message');
}
}
}
?>
.ss template
$submitForm
<% include Header %>
<form action="$Link" method="post" >
</form>
<% include Footer %>