graham73may / bolt-conditional-fields

A Bolt CMS extension to add conditional fields support to the backend.
MIT License
14 stars 5 forks source link

When conditional field was a repeater only the first set was hidden #9

Closed andy-morgan closed 7 years ago

andy-morgan commented 7 years ago

When the conditional was applied to a repeater field like so:

        template:
            type: templateselect
            filter: 'page_*.twig'

        carousel:
            type: repeater
            limit: 5
            fields:
                image:
                    type: image
                    extensions: [ gif, jpg, png ]
                strapline:
                    type: text
                contentlink:
                    type: text
                    label: Link
                    placeholder: '/slug or http://example.org/'

            condition:
                field: template
                operator: '='
                show: true
                value: [ "page_home.twig" ]

        body:
            type: html
            height: 300px
            condition:
                field: template
                operator: '!='
                show: true
                value: [ "page_home.twig" ]

Then instead of the whole repeater field being hidden, only the first set of the repeater was. This led to a broken interface like so:

screen shot 2017-10-23 at 13 36 17

Instead of the whole carousel field not being shown (which I believe is the intended behaviour).

graham73may commented 7 years ago

Hi,

Ah interesting! The way I use this extension means that I never really have any content in the field before toggling the conditional field so never experienced the repeater issue. Nice find!

Thanks for taking the time to submit a PR, I'll merge this in now.

P.s. Sorry took me so long to reply, this has been in my inbox for the past week but I've just been swamped at work.

graham73may commented 7 years ago

Just wanted to add an additional comment incase someone stumbles on this later. The extension (at the time of writing this) doesn't empty the field's value, it just hides the field.

So even if you have a repeater with content in that is hidden by a conditional field, the value will still be in the database and will still output on the frontend if your template doesn't also check the conditional field.