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:

All other Modules /

Discuss all other Modules here.

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

Advertisement module trouble


Go to End


3 Posts   1769 Views

Avatar
xesit

Community Member, 2 Posts

28 December 2010 at 9:55am

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

Avatar
patjnr

Community Member, 102 Posts

9 August 2011 at 12:23am

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

Avatar
xesit

Community Member, 2 Posts

9 August 2011 at 12:36am

Thanks.
At least I wrote my own module.