1779 Posts in 582 Topics by 556 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 544 Views |
-
Showing Custom form submissions in the CMS

31 March 2011 at 12:06am
HI,
I have created a custom form that submits ot the database. I would like to view the form submissions in the CMS in the same fashion as the userform module (I need more flexibility with my form that I get with the userform module).
Can somebody tell me what steps I need to take to get there?
Thanks,
Iain
-
Re: Showing Custom form submissions in the CMS

9 May 2011 at 6:32pm
you would need to have a look at TableListField.
I have a contact us form like this.
class ContactUsSubmission extends DataObject {
static $db = array(
'FirstName' => 'Varchar(255)',
'LastName' => 'Varchar(255)',
'Email' => 'Text',
'Comments' => 'Text',
'Subscribe' => 'Varchar(255)'
);
}I then added the contact us report under the Reports tab in my ContactUsPage.
function getCMSFields() {
$fields = parent::getCMSFields();
$fields->addFieldToTab('Root.Content.Main', new TextField('Headline'), 'Content');
$fields->addFieldToTab('Root.Reports.ContactUsReport', $this->getReportField());
return $fields;
}
function getReportField() {
$resultSet = new DataObjectSet();
$filter = '';
$sort = "ContactUsSubmission.ID ASC";
$join = '';
$instance = singleton('ContactUsSubmission');
$query = $instance->buildSQL($filter, $sort, null, $join);
$report = new TableListField(
'ContactUsSubmissionReport',
'ContactUsSubmission',
array(
'ID' => 'ID',
'Created' => 'Date/Time',
'FirstName' => 'First Name',
'LastName' => 'Last Name',
'Email' => 'Email Address',
'Comments' => 'Comments'
)
);
$report->setCustomQuery($query);
$report->setFieldFormatting(array(
'Email' => '<a href=\"mailto: $Email\" title=\"Email $FirstName\">$Email</a>'
));
$report->setFieldCasting(array(
'Created' => 'Date->Nice'
));
$report->setShowPagination(true);
if(isset($_REQUEST['printable'])) {
$report->setPageSize(false);
} else {
$report->setPageSize(20);
}
$report->setPermissions(array(
'export',
'delete',
'print'
));
return $report;
}
| 544 Views | ||
|
Page:
1
|
Go to Top |

