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.

Customising the CMS /

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

Relational dropdowns in CMS


Go to End


671 Views

Avatar
theoarena

Community Member, 1 Post

16 February 2017 at 4:20am

Hi!

I'm developing a custom CMS for my client and he needs to select a CITY filtered by a COUNTRY.

i have:

class Country extends DataObject
{
  static $has_many = array(
  'cities' => 'City'
);
}

class City extends DataObject
{
  static $has_one = array(
  'country' => 'Country '
);
}

I'd like to have two separate dropdown fields (or something similar) and be able to dynamically filter the cities.
i've heard of 'FilteredDropdownSet' but it looks deprecated now (i'm using SS 3.4).

How can i do that? I really can't figure out

Thanks in advance