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're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

Data Model Questions /

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

[SOLVED] Problem with Custom Table and DataObjectManager

Go to End



Community Member, 44 Posts

24 March 2009 at 6:35am

Edited: 24/03/2009 8:02am

Hello Everybody

i have Problems with my Custom Table and the DataObjectManager.
In my current Project is the case Locations. User can Submit a Location, all Locations are listed in a Table with a link to a detailed View.

1. Locations (All Locations - listed in Menu)
1.1 Add a Location (Submit - Listed in Menu)
1.2 Location (Detailview - not listed in Menu)

As i read the Polltutorial i created a Submission.php where my Table is set up, now i think doing it that way is wrong and won't work with my DataObjectManager. I think some Relations are messed up or i have 1 File too much.
Anyway... after 2 hours of trying to understand some Tutorials in the Docs i am stuck now and looking for Help.

Here are my PHP Files a Screenshot of my .ss Folder and a Screenshot of the Error i receieve on the Page "Location" in the CMS which is the Detailview.



	class Location extends Page {
		static $has_many = array(
			'Locations' => 'LocationSubmission'

		function getCMSFields() {
			$fields = parent::getCMSFields();
			$fields->addFieldToTab("Root.Content.Locations", new DataObjectManager(
				array('Name' => 'Name'),

			return $fields;

		// Get Location by ID (Detailview)
		function GetLocations()
			return DataObject::get('Location', 'ParentID = {$this->ID}', 'ID DESC');

	class Location_Controller extends Page_Controller {
		public function GetLocationSubmission(){
			$Params = Director::urlParams(); //This gets our URLparams
			$SubmissionID = $Params['Action']; //gets the ID from our $Params array
			return DataObject::get_by_id("LocationSubmission", "$SubmissionID");

		function ContactForm() {
		  // Create fields
		  $fields = new FieldSet(
		     new TextField('Dein Name'),
		     new TextareaField('Deine Nachricht')
		  	// Create actions
		$actions = new FieldSet(
		 new FormAction('ContactForm', 'Absenden')
		// Create validator
		$validator = new RequiredFields('Name', 'Deine Nachricht');
		return new Form($this, 'ContactForm', $fields, $actions, $validator);



	class LocationAdd extends Page {
	class LocationAdd_Controller extends Page_Controller {
		// Start Form
		function Form() {
			// Fields of Location
			$fields = new FieldSet(
				new TextField('Name','Name der Location'),
				new TextField('Author','Name des Ansprechpartners'),
				new EmailField('Email','E-Mail  des Ansprechpartners'),
				new TextareaField('Description','Beschreibe deine Location'),
				new TextField('Adress','Adresse'),
				new TextField('PLZ','PLZ'),
				new TextField('Location','Ort'),

				new DropdownField('Country','Land',array(
				#'' => '',
				  'Deutschland' => 'Deutschland',
				  'Schweiz' => 'Schweiz'
				new CheckboxSetField('Table','Kickertisch(e)',array(
			$actions = new Fieldset(
				new FormAction('addLocation','Eintragen')
			$validator = new RequiredFields(
			$form = new Form(
			return $form;
		// end Form
		// Dateneintrag
		function addLocation($data,$form) {
			$location = new LocationSubmission();
				'Eingetragen - wird geprŸft',
	// end Class


	class LocationSubmission extends DataObject {
		static $db = array(
			'Name' => 'Varchar(200)',
			'Author' => 'Varchar(100)',
			'Email' => 'Varchar (100)',
			'Description' => 'Text',
			'Adress' => 'Varchar(150)',  
			'PLZ' => 'Int(5)',   
			'Location' => 'Varchar(50)',
			'Country' => 'Varchar(50)',
			'Table' => 'Varchar(150)'   
		static $has_one = array(
			'LocationSubmission' => 'LocationSubmission'
		public function getCMSFields_forPopup()
			return new FieldSet(
				new TextField('Name')




	class LocationHolder extends Page {
		static $allowed_children = array(
		function LocationShow ()
			$sort = 'Created DESC';
			$data = DataObject::get('LocationSubmission','',$sort,'','');
			return $data;

	class LocationHolder_Controller extends Page_Controller  {



This kind of Case will come one more time in that Project and a few times in Future, so now i want to make sure i am doing the right way and looking for help here.

PLease show me what i am doing wrong.

Thank you all!

Attached Files