Hi,
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 ..
We've moved the forum!
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.
Have a read of tutorial 5 (http://doc.silverstripe.org/framework/en/tutorials/5-dataobject-relationship-management). 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.
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