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

Custom Form Template - How to display submitted data

Go to End

6 Posts   2098 Views


Community Member, 23 Posts

17 August 2010 at 6:25pm

Edited: 17/08/2010 6:26pm


I have implemented a custom form with custom template. Everything works (email gets sent, data it stored in database).

But I can't figure out how to display the submitted data. How do I list or display the submitted data?

Please see below for my code:


class RegisterPage extends Page {

    static $db = array(

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

class RegisterPage_Controller extends Page_Controller {

	function init() {
	function RegisterInterestForm() {
		return new RegisterForm($this, 'RegisterInterestForm');

RegisterForm.php - My Custom Form

class RegisterForm extends Form {

	function __construct($controller, $name) {
		// Create fields
		$fields = new FieldSet(
			new TextField('FirstName', 'First Name'),
			new TextField('Surname', 'Surname'),
			new TextField('Email', 'Email')			
		// Create actions
		$actions = new FieldSet(
			new FormAction('doSubmit', 'Submit')
		$validator = new RequiredFields('FirstName', 'Surname', 'Email');
		//return new Form($this, $name, $fields, $actions, $validator);
		parent::__construct($controller, $name, $fields, $actions, $validator);
	function doSubmit($data, $form) {
		$submission = new RegisterInterestSubmission();
	function forTemplate() {
		return $this->renderWith(array(

RegisterInterestSubmission.php - Data object to store submissions

class RegisterInterestSubmission extends DataObject {
	static $db = array(
		'FirstName' => 'Text',
		'Surname' => 'Text',
		'Email' => 'Text'


Community Member, 10 Posts

17 August 2010 at 9:10pm

Please note I have little experience in Silverstripe so there may be better options from the community.

From what I know I would suggest you would want to create a new page type which lists the data from the db/session/cookie and use a redirect on the submission page.


You could then display the data in an acceptable form.


Community Member, 23 Posts

17 August 2010 at 9:49pm

Thanks for the response but I am try to displaying the submitted data on the admin side. That is, on the CMS.


Community Member, 254 Posts

18 August 2010 at 2:46pm

Have you checked out the ModelAdmin class. If you make a class in mysite/code that extends model admin and add in the managed modules array
It should give you CRUD and a nice export to csv option ;)


Community Member, 23 Posts

18 August 2010 at 3:46pm

Thank you for the information. But I am not trying to add or edit data here. I simply want to display the data already stored in the database.

I added a new tab "Submission" and then tried using a ComplexTableField to list the data from the data object. That works partially. I get the list of submissions just fine. But when I try to view a row's details, I get an error.

Any pointers or ideas?


Community Member, 1 Post

19 October 2012 at 11:52pm

Similar problem: no errors, but list is empty.
Any advice is appreciated!