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.

DataObjectManager Module /

Discuss the DataObjectManager module, and the related ImageGallery module.

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

[DataObjectManager] - [Warning] DataObject::get_by_id passed a non-numeric ID #18


Go to End


3 Posts   3879 Views

Avatar
Lamin Barrow

Community Member, 22 Posts

12 May 2009 at 4:12am

Edited: 04/09/2009 9:16pm

Hello,

I have been working with DataOjectManager module for sometime now i am so much in love with the thing. Recently i have been having the following stack trace error pop up whenever i try post a new image using a new page type i have recently created. I can see that everything saves just after i close the fancybox window but the initial saving is where the problem is. Below is some of the stack trace error code.

[Warning] DataObject::get_by_id passed a non-numeric ID #18
POST /projectName/admin/EditForm/field/Homes/UploadForm?ctf[Homes][per_page]=10&ctf[Homes][showall]=0&ctf[Homes][sort]=Created&ctf[Homes][sort_dir]=DESC&ctf[Homes][search]=&ctf[Homes][filter]=&ctf[Homes][view]=grid&ctf[Homes][imagesize]=100

Line 2413 in C:\wamp\www\projectName\sapphire\core\model\DataObject.php

This is the code for the new page type class extending the DataObject class

<?php

class Home extends DataObject
{
	static $db = array (
		'Name' => 'Text',
		'PhotoDescription' => 'HTMLText(1024)'
	);
	
	static $has_one = array (
		'Photo' => 'Image',
		'HomePage' => 'HomePage'
	);
		
	public function getCMSFields_forPopup()
	{
		return new FieldSet(
			new TextField('Name'),
			new TextareaField('PhotoDescription', 'Photo Description'),
			new ImageField('Photo')
		);
	}
}
?>

and finally here is some of the code for the PageType Model itself

class HomePage extends Page 
{
	
   static $db = array(
   		//'Introduction' => 'HTMLVarchar',
   		'GoalsAndObjectives' => 'HTMLVarchar(5000)'		
   );
   static $has_one = array(
  		"InternalLink" => "SiteTree",
   );
   
   static $has_many = array (
		'Homes' => 'Home'
	);


   static $icon = "themes/light/images/treeicons/home";
 

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

		$manager = new ImageDataObjectManager(
			$this, // Controller
			'Homes', // Source name
			'Home', // Source class
			'Photo', // File name on DataObject
			array(
				'Name' => 'Name', 
				'PhotoDescription' => 'PhotoDescription'
			), // Headings 
			'getCMSFields_forPopup' // Detail fields (function name or FieldSet object)
			// Filter clause
			// Sort clause
			// Join clause
		);
		
		$fields->addFieldToTab("Root.Content.Photo Slide Show", $manager);
	   	$fields->addFieldToTab("Root.Content.Featured Link", new TreeDropdownField("InternalLinkID", "InternalLink", "SiteTree"));
		$fields->addFieldToTab("Root.Content.Main", new HTMLEditorField("GoalsAndObjectives", "Goals and Objectives"));
		
		return $fields; 
		
	}

	
}

I am running the Latest SVN build (142) of the DOM module. This is my first forum post here and also the first time i am have encountered an error like this. Any help will be greatly appreciated. Thank you. :D

Avatar
UncleCheese

Forum Moderator, 4102 Posts

13 May 2009 at 1:55am

Let me just make sure I know exactly where the error is happening.

You upload one or many images, they get accepted, and then it walks you through each one in the "Editing Image 1 of XXX" form. When you click save on the form, it throws the error? But when you close the modal window, everything is fine?

Avatar
Lamin Barrow

Community Member, 22 Posts

13 May 2009 at 4:31am

Edited: 04/09/2009 9:17pm

The error comes after i hit the upload button and then whole process dies. This is the entire error trace log is showed me this time.

[Warning] DataObject::get_by_id passed a non-numeric ID #21
POST /projectName/admin/EditForm/field/Homes/UploadForm?ctf[Homes][per_page]=10&ctf[Homes][showall]=0&ctf[Homes][sort]=Created&ctf[Homes][sort_dir]=DESC&ctf[Homes][search]=&ctf[Homes][filter]=&ctf[Homes][view]=grid&ctf[Homes][imagesize]=100

Line 2413 in C:\wamp\www\ projectName\sapphire\core\model\DataObject.php
Source
2404 				$tableClasses = ClassInfo::dataClassesFor($callerClass);
2405 				$baseClass = array_shift($tableClasses);
2406 				return DataObject::get_one($callerClass,"`$baseClass`.`ID` = $id");
2407 
2408 				// This simpler code will be used by non-DataObject classes that implement DataObjectInterface
2409 			} else {
2410 				return DataObject::get_one($callerClass,"`ID` = $id");
2411 			}
2412 		} else {
2413 			user_error("DataObject::get_by_id passed a non-numeric ID #$id", E_USER_WARNING);
2414 		}
2415 	}
2416 
2417 	/**
2418 	 * Get the name of the base table for this object
2419 	 */
Trace
DataObject::get_by_id passed a non-numeric ID #21 
Line 2413 of DataObject.php
DataObject::get_by_id(Home,21) 
Line 363 of FileDataObjectManager.php
FileDataObjectManager->EditUploadedForm() 
Line 315 of FileDataObjectManager.php
FileDataObjectManager->saveUploadForm(Array,ImageDataObjectManager_Popup,HTTPRequest) 
Line 228 of Form.php
Form->httpSubmission(HTTPRequest) 
Line 107 of RequestHandler.php
RequestHandler->handleRequest(HTTPRequest) 
Line 121 of RequestHandler.php
RequestHandler->handleRequest(HTTPRequest) 
Line 121 of RequestHandler.php
RequestHandler->handleRequest(HTTPRequest) 
Line 121 of RequestHandler.php
RequestHandler->handleRequest(HTTPRequest) 
Line 122 of Controller.php
Controller->handleRequest(HTTPRequest) 
Line 277 of Director.php
Director::handleRequest(HTTPRequest,Session) 
Line 121 of Director.php
Director::direct(/admin/EditForm/field/Homes/UploadForm) 
Line 115 of main.php

So after i close the fancybox window, i can see that all the images i uploaded are there and that i can edit the various text fields but when i try replace the image i am getting it throws up this error

[Notice] Undefined index: ImageSource
line 706 in C:\wamp\www\ projectName\sapphire\core\model\Image.php

I know the fault is possibly in my code but I dont know where to find it.