Hi Guy,
Not entirely sure what you mean but take a look at this, it's the same principle:
Aram
www.ssbits.com - Your one stop SilverStripe learning resource.
This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.
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.
Discuss the DataObjectManager module, and the related ImageGallery module.
Moderators: martimiz, UncleCheese, Sean, Ed, biapar, Willr, Ingo, swaiba
Hi Guy,
Not entirely sure what you mean but take a look at this, it's the same principle:
Aram
www.ssbits.com - Your one stop SilverStripe learning resource.
@guywatson - did u manage to find a solution to this?
I'm having the same issue. I saw that the constructed query only select fields from the first table in the DataObjectManager even if you JOIN another table. If I can find a way to add the required field to the select query, it would solve my problem (I hope). It also ads a GROUP BY clause, which would make it challenging to add another field in the query.
Any help guys? I started a topic on this exact issue which I assume is related here (http://www.silverstripe.org/dataobjectmanager-module-forum/show/18446).
Hi ROlckers
This seems to be a problem with dom, because it works fine with complex table fields. I still needed to use a dom however so the way i got around it was to create a get function on the CustomModel dataobject i.e. something like this
public function getCustomParentPageTitle() {
return $this->CustomParentPage()->Title;
}
Then in the XYZ Page
public function getCMSFields() {
$fields = parent::getCMSFields();
$fields->addFieldToTab("Root.Content.CustomWidgets", new DataObjectManager(
$this,
'CustomModels',
'CustomModel',
array( 'CustomName' =>'Custom Model Name',
'CustomParentPageID' =>'Custom Parent Page ID'
'CustomParentPageTitle' =>'Custom Parent Title' ),
' getCMSFields_forPopup'
));
return $fields;
}
Note you omit the get and CustomParentPageTitle is the function call on the dataobject
Also you should just be able to go CustomParentPageID.Title, but this doesn't work for me (well on a many_many relationship) i haven't tried a has_many relationship
Guy
Great, I'll play around with that. Thanks.
Legend! I took the $has_one column id, and used that inside the function, there I could use any calculation to get the Title from SiteTree or from another model.