Jump to:

5521 Posts in 1733 Topics by 1220 members

Customising the CMS

SilverStripe Forums » Customising the CMS » How to dynamically populate dropdownfield2 in popup based on selection of dropdownfield1?

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

Page: 1
Go to End
Author Topic: 1563 Views
  • t_agga
    Avatar
    Community Member
    7 Posts

    How to dynamically populate dropdownfield2 in popup based on selection of dropdownfield1? Link to this post

    Hi guys,

    Apart from other fields, I have two dropdownfields in my Popup. I managed to get them populated with data. However, as there is a one-to-many relationship between them, I would like the second combo to be dynamically populated with the data specific to the first one. At the moment I get all the values in a second combo regardless of combo1. Is there a way to do it? And how can I find out if the state of the dropdownfield has been changed and how can I get the value?
    I spent days on silverstripe doc, trying to find the answer but no luck.
    Thank you in advance.

  • t_agga
    Avatar
    Community Member
    7 Posts

    Re: How to dynamically populate dropdownfield2 in popup based on selection of dropdownfield1? Link to this post

    Hi guys,
    Has anybody attempted to add conditional fields in Popup at all? I managed to update a textfield on the selection of dropdownfield, with the value from that dropdownfield in a tab of admin (used behaviour js file). But no luck with Popup.
    Any thoughts guys?
    Just let me know if it is possible. Otherwise I will let my boss know that it's not going to happen and we will look at alternatives.
    Thanks so much.

  • Hamish
    Avatar
    Community Member
    712 Posts

    Re: How to dynamically populate dropdownfield2 in popup based on selection of dropdownfield1? Link to this post

    At this stage I believe not.

    This is a guess, but I think you can't load scripts from a popup, so you can't add the behaviour properly. You'd have to do something really hacky. My answer would be try it another way.

  • Hamish
    Avatar
    Community Member
    712 Posts

    Re: How to dynamically populate dropdownfield2 in popup based on selection of dropdownfield1? Link to this post

    Which makes me think - do tree views work from popups? That would be a good way of handling it in a single field. Eg, say your two dropdowns where countries -> city, you could put them together in a single tree view:

    + New Zealand
    ---- Auckland
    ---- Christchurch
    ---- Hamilton
    ---- Wellington
    + Australia
    ---- Adelaide
    ---- Canberra
    ...

  • Andrew Houle
    Avatar
    Community Member
    132 Posts

    Re: How to dynamically populate dropdownfield2 in popup based on selection of dropdownfield1? Link to this post

    This is a feature that I've tried to add as well, but with no success. This is definitely something I'd like to be able to do. Maybe someone has gotten a hack to work, or maybe it's something that can be added in a later release?

    1563 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.