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.

Customising the CMS

SS_Report + getReportField


Reply

948 Views

Avatar
IOTI

16 June 2010 at 2:50am (Last edited: 16 June 2010 4:29am), Community Member, 189 Posts

Hello

I'm trying to use getReportField to display a ComplexTableField but i'm having a very hard time figuring out how to do it.

<?php

/**
* An extension to {@link SSReport} that allows a user to view all, booked, and not booked reports
*/

/**
*Gets all Rental Requests
*
*/
class AllRentalRequestReport extends SS_Report {
      
      function title() {
         
         return 'All Rental Requests';
      }
      
      function description() {
         
         return 'All Rental Requests';
      }
      
   
   function getReportField(){
      $CTF = new ComplexTableField(
            'BookingFormSubmission',
            'All Rental Requests Report',
            'BookingFormSubmission',
            $fieldList = array(
               'ID' => 'ID',         
               'FirstName' => 'First Name',
               'LastName' => 'Last Name'
            )
            
      );
      $CTF->setParentClass('BookingFormSubmission');
      
      return $CTF;
   }
   
}

?>

BookingFormSubmission is a class that has several fields, nothing more

<?php
/*
* Custom class used to process Booking request form
*/

class BookingFormSubmission extends DataObject {
         
         
         static $db = array (
            'FirstName' => 'Text',
            'LastName' => 'Text',
            'Email' => 'Text',
            'PhoneNumber' => 'Text',
            'ArrivalDate' => 'Text',
            'DepartureDate' => 'Text',
            'Guests' => 'Text',
            'AdditionalQuestions' => 'Text',
            'Booked' => 'Boolean'
         );
}

?>

I can't get the ComplexTableField form to show up in the CMS. I believe I am doing something wrong with the ComplextableField constructor but just not sure how to make it work correctly. Any guidance would be nice.

I've already tried looking at
[url]http://doc.silverstripe.org/complextablefield[/url] and [url]http://doc.silverstripe.org/complextablefieldexamples[/url] but still confused.

Thank you