Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Form Questions /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Add a contact form to the footer

Go to End

2 Posts   1850 Views


Community Member, 7 Posts

21 May 2010 at 3:59pm

How if possible do I go about adding my content form to the footer, preferably as an include as i would like it on all pages. I used: in templates/layout/

<div id="LeftColumn"></div>
<div class="typography">


<% if Success %>
<% else %>
<% end_if %>


ContactPage.php: in mysite/code/

/* *****************
* Model
class ContactPage extends Page
static $db = array(
'Mailto' => 'Varchar(100)', //Email address to send submissions to
'SubmitText' => 'HTMLText' //Text presented after submitting message

//CMS fields
function getCMSFields() {
$fields = parent::getCMSFields();

$fields->addFieldToTab("Root.Content.OnSubmission", new TextField('Mailto', 'Email submissions to'));
$fields->addFieldToTab("Root.Content.OnSubmission", new HTMLEditorField('SubmitText', 'Text on Submission'));

return $fields;

/* *****************
* Controller
class ContactPage_Controller extends Page_Controller
function ContactForm() {
// Create fields
$Params = Director::urlParams();

$fields = new FieldSet(
new TextField('Name', 'Name*'),
new EmailField('Email', 'Email*'),
new TextareaField('Comments','Comments*')

// Create action
$actions = new FieldSet(
new FormAction('SendContactForm', 'Send')
// Create action
$validator = new RequiredFields('Name', 'Email', 'Comments');

return new Form($this, 'ContactForm', $fields, $actions, $validator);

function SendContactForm($data) {

//Set data
$From = $data['Email'];
$To = $this->Mailto;
$Subject = "Website Contact message";
$email = new Email($From, $To, $Subject);
//set template
//populate template
//send mail
//return to submitted message
Director::redirect(Director::baseURL(). $this->URLSegment . "/?success=1");


public function Success()
return isset($_REQUEST['success']) && $_REQUEST['success'] == "1";

...and my is just an include:

I have successfully created a contact page that is visible when on the actual page from main nav, but I would like to have just the form appear within the footer. What do I need to do next? Do I need a holder page?



Community Member, 165 Posts

23 May 2010 at 10:59am

If the Footer is an include, I think you need to flush the cache

before the changes become visible. Did you try that?