Conditional Fields in blueprint

Can’t seem to get a conditional field to work in a Blueprint when a select option is used.
In the following it is the field ‘condition’ under ‘thirdparty’ that is causing me pain.
(This is a part of a plugin’s blueprints.yaml file.)

        provider:
            type: select
            label: Map imagery provider
            options:
                openstreetmap: Open Street Map
                thunderforest: Thunderforest
                mapbox: Mapbox
            default: openstreetmap
        thirdparty:
            type: conditional
            condition: "config.plugins.map-leaflet.provider == 'openstreetmap' ? 'true' : 'false' "
            fields:
                apikey:
                    type: text
                    label: API Key if provider needs it
                    help: You should register your own API key with the provider and include it here
                    default:  'querty'

I have tried is same as instead of == in condition, but I still get problems.

I save the change each time. I have got conditional fields working before in blueprints, but only with fields that themselves were boolean.

I can’t figure out what I am doing wrong.

@finanalyst I’m just guessing that the condition is parsed and executed by Javascript. The dash in ‘map-leaflet’ might cause problems.

What if you try:

"config.plugins['map-leaflet'].provider == 'openstreetmap' ? 'true' : 'false' "

Again, just guessing…

The GRAV documentation says the string is processed with twig. When I made an error in the string, I got an error message from the Twig processor.

I’ll try your workaround.

Further: The following worked:

"config.plugins['map-leaflet'].provider == 'openstreetmap' "

WIth the ? 'true' : 'false' part, it did not.

Thanks

Glad it’s working…

Twig variables:
Also Twig does not handle variables containing a dash.

When the attribute contains special characters (like - that would be interpreted as the minus operator) […]

Twig truthy-ness:

The rules to determine if an expression is true or false are the same as in PHP;

Which means that both strings ‘false’ and ‘true’ returned by your condition are true. Does that align with your experience?

I wonder if the example in Grav’s docs about the Conditional Field using the quoted false and true is correct…

About ‘true’ and ‘false’, I think you are right, and it certainly is what I found.

Thanks for the quick response and the ‘-’ tip. I know there is a problem with ‘-’, but I haven’t yet worked out quite where. Sometimes I can use is, sometimes not. Your point about Twig and ‘-’ is helpful.

That would indicate the GRAV documentation is not correct, unless I am missing something.