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

SS3 Display Submissions table


Reply

3 Posts   506 Views

Avatar
merrick_sd

22 November 2012 at 5:17am Community Member, 95 Posts

I have a custom Form and it is saving data to a table called 'ContactSubmissions'

Question: How can i display these in the admin area?

Trying to get this to work using silverstripe 3.

can Datagrids be display only?

Attached Files
Avatar
merrick_sd

23 November 2012 at 2:33am (Last edited: 23 November 2012 2:38am), Community Member, 95 Posts

answering my own questions again

   function getCMSFields()
   {
      $fields = parent::getCMSFields();
   
      $fields->addFieldToTab("Root.OnSubmission", new TextField('Mailto', 'Email submissions to'));   
      $fields->addFieldToTab("Root.OnSubmission", new HTMLEditorField('SubmitText', 'Text on Submission'));
      
      
      $gridFieldConfig = GridFieldConfig_RecordViewer::create();
      $gridfield = new GridField("ContactSubmission", "Submissions", ContactSubmission::get(), $gridFieldConfig);
      $fields->addFieldToTab('Root.Submissions', $gridfield);
         
      
      return $fields;   
   }

}

I'd like to include an export to csv button next is that possible anyone? GridField_ActionProvider?

Avatar
rohitbanerjee

28 December 2012 at 9:54am Community Member, 7 Posts

Don't know if you already got the answer, if not then rewrite your code as below:

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

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

$gridFieldConfig = GridFieldConfig_RecordViewer::create()->addComponents(
      new GridFieldToolbarHeader(),
      new GridFieldSortableHeader(),
      new GridFieldFilterHeader(),
      new GridFieldDataColumns(),
      new GridFieldPaginator(),
      new GridFieldExportButton()
   );
$gridfield = new GridField("ContactSubmission", "Submissions", ContactSubmission::get(), $gridFieldConfig);
$fields->addFieldToTab('Root.Submissions', $gridfield);

return $fields;
}

I hope this should get you started ...