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:

Data Model Questions /

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

How to Relate Dataobject with page?

Go to End

3 Posts   848 Views


Community Member, 11 Posts

29 January 2014 at 5:44pm

I am new to silverstripe ,I need to create Dataobject(Ex:-CarAcs extends ModelAdmin) that is related to pages what ever you created in Dataobject it will showen as dropdown menu in page so we can realate data and show it in page , Please given me a simple example of doing it with all code thanks in advance ..


Forum Moderator, 5523 Posts

29 January 2014 at 8:02pm

Have a read of tutorial 5 ( This will explain relationships and the concept of relating objects in SilverStripe.

On your Page class you might have something like

private static $has_one = array(
"Car" => "CarAcs"

Then in your getCMSFields for Page add the DropdownField.

public function getCMSFields() {
$fields = parent::getCMSFields();
$fields->addFieldToTab('Root.Main', new DropdownField('CarID', 'Car', CarAcs::get()->map('ID', 'Title')));

return $fields;

Where 'CarAcs' is the name of your class. This relationship will add $page->Car() to get the car.


Community Member, 11 Posts

29 January 2014 at 8:12pm

Again Thanx bro, your always there for help.

Can you help one more time..

I need to get all infomation from Related to Cars object and pass it to view .... Please