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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Customising the CMS /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

SS_Report + getReportField


Go to End


1479 Views

Avatar
copernican

Community Member, 189 Posts

16 June 2010 at 2:50am

Edited: 16/06/2010 4:29am

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
http://doc.silverstripe.org/complextablefield and http://doc.silverstripe.org/complextablefieldexamples but still confused.

Thank you