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   559 Views

Avatar
merrick_sd

Community Member, 97 Posts

22 November 2012 at 5:17am

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

Community Member, 97 Posts

23 November 2012 at 2:33am

Edited: 23/11/2012 2:38am

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

Community Member, 7 Posts

28 December 2012 at 9:54am

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 ...