Jump to:

7935 Posts in 1536 Topics by 943 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » [DataObjectManager] - [Warning] DataObject::get_by_id passed a non-numeric ID #18

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Page: 1
Go to End
Author Topic: 2510 Views
  • Lamin Barrow
    Avatar
    Community Member
    21 Posts

    [DataObjectManager] - [Warning] DataObject::get_by_id passed a non-numeric ID #18 Link to this post

    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.

  • UncleCheese
    Avatar
    4085 Posts

    Re: [DataObjectManager] - [Warning] DataObject::get_by_id passed a non-numeric ID #18 Link to this post

    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?

  • Lamin Barrow
    Avatar
    Community Member
    21 Posts

    Re: [DataObjectManager] - [Warning] DataObject::get_by_id passed a non-numeric ID #18 Link to this post

    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.

    2510 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.