7938 Posts in 1541 Topics by 945 members
|Go to End|
21 September 2012 at 6:58pm
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.
18 October 2012 at 4:23am Last edited: 18 October 2012 4:24am
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 withas this will retrieve all of the products with a category of fruit, for example, if that is what is selected in the other dropdown.
DataObject::get("Product", "Category = '" . $dropdown.val() . "'");
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.
|Go to Top|