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

Dynamic form in back-end (AJAX?)


Go to End


3 Posts   1009 Views

Avatar
Faloude

Community Member, 55 Posts

13 October 2016 at 3:48am

Edited: 13/10/2016 3:49am

Suppose you have a DataObject named Food. Users can add records using the GridField. When clicking on a GridField to enter detail view, there is a
DropdownField Type with values:

  • Fruit
  • Vegetables

Then there is a second DropdownField Product When Type is set to Fruit, the values for the second DropdownField are: Apples and Oranges.
If Type is set to Vegetables, the values will be Broccoli and Spinach.

I need to create a dynamic DataObject as such, but I don't know where to begin. This kind of flexibility seems to challenge the framework's flexibility.

  • Would I need to create all $db columns in one table?
  • Does this rely on AJAX?
  • Does anyone have an example code of something that comes close to this?

Avatar
muskie9

Community Member, 24 Posts

13 October 2016 at 3:53am

A good starting point for this type of need would be Shea Dawson's dependent dropdown module: https://github.com/sheadawson/silverstripe-dependentdropdownfield

Avatar
Faloude

Community Member, 55 Posts

13 October 2016 at 6:36am

Great module, although it's for 'dependant' DropdownFields only.

This module includes all kinds of fieldtypes: https://github.com/unclecheese/silverstripe-display-logic