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.

DataObjectManager Module

Discuss the DataObjectManager module, and the related ImageGallery module.

Moderators: martimiz, UncleCheese, Sean, biapar, Willr, Ingo, swaiba, simon_w

FilteredDropdownSet - Simple Static Example Wanted


Reply

2 Posts   581 Views

Avatar
markeaston

21 September 2012 at 6:58pm Community Member, 11 Posts

Hi

I'm completely new to SilverStripe and need a very simple set of drop down fields in a hierarchy. From the sounds of things the FilteredDropDown set would be perfect but I don;t really need to put the values in a database.

Can someone please provide a brief example of how I would get it working for basic static data.

e.g. set up the first drop down with 'fruit' and 'vegetable' and the second with 'apple','pear','peach','carrot','potato' linking to the correct parent.

Thanks

Avatar
Stef87

18 October 2012 at 4:23am (Last edited: 18 October 2012 4:24am), Community Member, 66 Posts

Hi Markeaston

Unfortunately one of your dropdowns will need to be populated with DataObjects from the database as the easiest way you can achieve this is by querying with

DataObject::get("Product", "Category = '" . $dropdown.val() . "'");

as this will retrieve all of the products with a category of fruit, for example, if that is what is selected in the other dropdown.

I don't have time right now to write up the code but I'll be doing so in a few days if you can wait or if you can't, you use FilterDropDown as a jumping off point. You should be able to structure something in a similar way.