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

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

How to relate has_one in the ModelAdmin???????


Go to End


2 Posts   685 Views

Avatar
silversunhunter

Community Member, 6 Posts

21 June 2016 at 10:57am

I am using ModelAdmin to manage a dataObject called $Car
Each $Car can have one $Driver

There are thousands of drivers to choose from!

When I create a new $Car I want to be able to search the db of drivers and select one to assign it to the car. How do I do that?

Avatar
martimiz

Forum Moderator, 1391 Posts

26 June 2016 at 10:22pm

Maybe the PickerField would work for you: http://addons.silverstripe.org/add-ons/briceburg/silverstripe-pickerfield

It is GridField based and supposed to handle has_one relations, so it should allow for selecting a driver based on multiple criteria. Of course you'd need to write your own getCMSFields for the Car object.