Jump to:

10931 Posts in 2614 Topics by 1810 members

All other Modules

SilverStripe Forums » All other Modules » Advertisement module trouble

Discuss all other Modules here.

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

Page: 1
Go to End
Author Topic: 1070 Views
  • xesit
    Avatar
    Community Member
    2 Posts

    Advertisement module trouble Link to this post

    Hello,
    I installed a new module by Nicolaas Francken (Advertisement).
    But when I want to add any ad in my admin I still got an error:

    Debug (Advertisement->getCMSFields() in line 93 of Advertisement.php) Debug (Advertisement->getCMSFields() in line 93 of Advertisement.php) ERROR [User Error]: Orphaned $belongs_many_many value for Advertisement.Parents IN POST /lab/admin/ads/Advertisement/AddForm?action_doCreate=Dodaj Line 1761 in /home/xesit/ftp/lab/sapphire/core/model/DataObject.php Source ====== 1752: $parentField = ($class == $candidate) ? "ChildID" : $candidateClass . "ID"; 1753: // HACK HACK HACK! 1754: if($component == 'NestedProducts') { 1755: $parentField = $candidateClass . "ID"; 1756: } 1757: 1758: return array($class, $candidate, $parentField, $childField, "{$candidate}_$inverseComponentName"); 1759: } 1760: } * 1761: user_error("Orphaned \$belongs_many_many value for $this->class.$component", E_USER_ERROR); 1762: } 1763: } else { 1764: $newItems = (array) Object::uninherited_static($class, 'many_many'); 1765: // Validate the data 1766: foreach($newItems as $k => $v) { 1767: if(!is_string($k) || is_numeric($k) || !is_string($v)) user_error("$class::\$many_many has a bad entry: " Trace =====

    user_error(Orphaned $belongs_many_many value for Advertisement.Parents,256) line 1761 of DataObject.php DataObject->many_many(Parents) line 1471 of DataObject.php DataObject->getManyManyFilter(Parents,SiteTree) line 149 of FormScaffolder.php FormScaffolder->getFieldSet() line 1908 of DataObject.php DataObject->scaffoldFormFields(Array) line 1943 of DataObject.php DataObject->getCMSFields() line 94 of Advertisement.php Advertisement->getCMSFields() line 941 of ModelAdmin.php ModelAdmin_RecordController->EditForm() line 865 of ModelAdmin.php ModelAdmin_CollectionController->doCreate(Array,Form,SS_HTTPRequest) line 300 of Form.php Form->httpSubmission(SS_HTTPRequest) line 137 of RequestHandler.php RequestHandler->handleRequest(SS_HTTPRequest) line 155 of RequestHandler.php RequestHandler->handleRequest(SS_HTTPRequest) line 147 of Controller.php Controller->handleRequest(SS_HTTPRequest) line 155 of RequestHandler.php RequestHandler->handleRequest(SS_HTTPRequest) line 147 of Controller.php Controller->handleRequest(SS_HTTPRequest) line 281 of Director.php Director::handleRequest(SS_HTTPRequest,Session) line 124 of Director.php Director::direct(/admin/ads/Advertisement/AddForm) line 127 of main.php

    I dont have any more ideas. Any help will be nice.
    Thank in advance.

    Daniel

  • patjnr
    Avatar
    Community Member
    101 Posts

    Re: Advertisement module trouble Link to this post

    When you have relationships like this

    say this object is Listing

    static $has_one = array(
    'Member' => 'Member',
    );

       static $many_many = array(
          'Subscribers' => 'Member'
       );

    The above code will generate an "Orphaned $belongs_many_many value".
    The $has_one will create a db field called MemberID
    $many_many will create a table called Listing_Subscribers with also a db field called MemberID.

    the resulting DataObject::get sql query will always join these two table.

    The solution is to change the relationship name on the $has_one to ..

    static $has_one = array(
    'Owner' => 'Member',
    );

    hope this helps

    PJ

  • xesit
    Avatar
    Community Member
    2 Posts

    Re: Advertisement module trouble Link to this post

    Thanks.
    At least I wrote my own module.

    1070 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.