Skip to content
This repository was archived by the owner on Mar 7, 2021. It is now read-only.

How do I show/hide fields in a dynamic section? #508

Open
uzegonemad opened this issue Feb 5, 2016 · 1 comment
Open

How do I show/hide fields in a dynamic section? #508

uzegonemad opened this issue Feb 5, 2016 · 1 comment

Comments

@uzegonemad
Copy link

I can't seem to figure out how to show/hide child fields inside a dynamic section.

I've tried using parent[:index].child but it causes a crash. I also tried parent.child thinking it might not require an index, but it also crashes.

My sample JSON is below. When "targeted sales funnel" is no, both the + field and all of the "year" rows should disappear. Currently, only the + field disappears.

Any insight is much appreciated!

Here's my sample JSON:

{
    "groups": [
        {
            "id": "sales-funnel",
            "title": "Targeted Sales Funnel",
            "sections": [
                {
                    "id": "is-sales-funnel",
                    "fields": [
                        {
                            "id": "is_sales_funnel",
                            "title": "This contact is in the targed sales funnel",
                            "type": "select",
                            "values": [
                                {
                                    "id": 0,
                                    "title": "No",
                                    "default": true,
                                    "targets": [
                                        {
                                            "id": "sales-funnel-years",
                                            "type": "section",
                                            "action": "hide"
                                        }
                                    ]
                                },
                                {
                                    "id": 1,
                                    "title": "Yes",
                                    "targets": [
                                        {
                                            "id": "sales-funnel-years",
                                            "type": "section",
                                            "action": "show"
                                        }
                                    ]
                                }
                            ]
                        }
                    ]
                },
                {
                    "id": "sales-funnel-years",
                    "hidden": true,
                    "type": "dynamic",
                    "action_title": "Add Sales Funnel Year ✛",
                    "fields": null
                }
            ]
        }
    ],
    "templates": {
        "sections": [
            {
                "id": "sales-funnel-years",
                "fields": [
                    {
                        "id": "sales-funnel-years[:index].year",
                        "title": "Year",
                        "type": "select",
                        "size": {
                            "width": 80,
                            "height": 1
                        },
                        "values": [
                            {
                                "id": 2015,
                                "title": "2015",
                            },
                            {
                                "id": 2016,
                                "title": "2016",
                            },
                            {
                                "id": 2017,
                                "title": "2017",
                            },
                        ]
                    },
                    {
                        "id": "sales-funnel-years[:index].remove",
                        "title": "Remove",
                        "type": "button",
                        "size": {
                            "width": 20,
                            "height": 1
                        }
                    }
                ]
            }
        ]
    }
}
@3lvis
Copy link
Owner

3lvis commented Feb 9, 2016

Hi @uzegonemad,

I'm sorry for not replying earlier, hard week at work. Will have a look at your issue later this week.

@3lvis 3lvis self-assigned this May 3, 2016
@3lvis 3lvis removed their assignment Jan 21, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants