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.

Archive /

Our old forums are still available as a read-only archive.

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

Questions about custom forms

Go to End



Community Member, 8 Posts

3 October 2007 at 3:14am


I am creating a new page type for our ss site that includes a form. I am creating this instead of using the existing contact form page type so that my users don't have to create the same registration form everytime they add an event to our site. I have run into two issues that I cannot resolve.

The first is getting the form fields to show up in the submissions tab in the cms. The data from the form is making it into the database, but only the date/time of the submission is appearing on the submissions tab. I assume I am neglecting some detail, but I don't know what it is. Here are my class and controller:

* Defines the EventPage page type

class EventPage extends Page {
static $db = array(
'Date' => 'Date',
'Time' => 'Text',
'Location' => 'Text',
'Meeting_time' => 'Text',
'Meeting_place' => 'Text',
'Registration_required' => 'Boolean',
'Map' => 'Text',
'Author' => 'Text',
"OnCompleteMessage" => "HTMLText"

static $has_one = array(

static $has_many = array(
"Submissions" => "EventRegisterFormSubmission"

static $icon = "mysite/images/treeicons/news";

static $defaults = array(
'ProvideComments' => false,
"OnCompleteMessage" => "<p>Thanks, we've received your registration.</p>",


function getCMSFields() {
$fields = parent::getCMSFields();
$fields->addFieldToTab('Root.Content.Main', new CalendarDateField('Date', 'Date of event'), 'Content');
$fields->addFieldToTab('Root.Content.Main', new TextField('Time', 'Time of event'), 'Content');
$fields->addFieldToTab('Root.Content.Main', new TextField('Location', 'Location of event'), 'Content');
$fields->addFieldToTab('Root.Content.Main', new TextField('Meeting_time', 'Carpool meeting time'), 'Content');
$fields->addFieldToTab('Root.Content.Main', new TextField('Meeting_place', 'Carpool meeting place'), 'Content');
$fields->addFieldToTab('Root.Content.Main', new TextField('Map', 'Map to event'), 'Content');
$fields->addFieldToTab('Root.Content.Main', new TextField('Author'), 'Content');
$fields->addFieldToTab('Root.Content.Main', new CheckboxField('Registration_required', 'Check if registration required'), 'Content');
$fields->addFieldToTab("Root.Content.On complete", new HtmlEditorField( "OnCompleteMessage", "Show on completion",3,"",$this->OnCompleteMessage, $this ) );
$fields->addFieldToTab("Root.Submissions", new SubmittedFormReportField( "Reports", "Received Registrations", "", $this ) );
return $fields;


class EventPage_Controller extends Page_Controller {

function EventRegisterForm() {

//create the fields for the registration form
$nameField = new TextField('Name');
$emailField = new EmailField('Email');
$hiddenField = new HiddenField('ParentID');

//put the fields into a fieldset
$fields = new FieldSet(

// Create validator
$validator = new RequiredFields('Name', 'Email');

//create an action and a submit button for the form

$submitAction = new FormAction('doEventRegisterForm', 'Submit');

//put the submit button into a field set
$actions = new FieldSet(

//return the form with the fields and the action
return new Form($this, 'EventRegisterForm', $fields, $actions, $validator);

function doEventRegisterForm($data, $form) {
$submission = new EventRegisterFormSubmission();
$submission->ParentID = $this->ID;
$submission->Name = $_POST['Name'];
$submission->Email = $_POST['Email'];



I also don't know how to get the "On complete message" to display once the form has been submitted.

Thanks for the help.