ideas icon indicating copy to clipboard operation
ideas copied to clipboard

Make it possible to use `without target` conditions with others

Open aerni opened this issue 3 years ago • 2 comments

I ran into a situation where I need to use multiple field conditions including one custom condition without target. Currently, you can only either set multiple conditions with a target OR one condition without target. You can't mix and match.

This is my field:

[
    'handle' => 'seo_section_sitemap',
    'field' => [
        'type' => 'section',
        'if' => [
            'showSitemapFields',
            'seo_noindex.value' => 'false',
            'seo_canonical_type.value' => 'equals current',
        ],
    ],
],

aerni avatar Aug 25 '22 23:08 aerni

As a workaround, you could do the following, no?

[
    'handle' => 'seo_section_sitemap',
    'field' => [
        'type' => 'section',
        'if' => [
            'showSitemapFields' => 'custom showSiteMapFields',
            'seo_noindex.value' => 'false',
            'seo_canonical_type.value' => 'equals current',
        ],
    ],
]

The condition handler doesn't care that the field doesn't actually exist, and the data passed to the function is the same, except that target is null (but it's not used anyway).

Narretz avatar Aug 26 '22 10:08 Narretz

This works, thanks! My suggestion would only be syntactic sugar then.

aerni avatar Aug 26 '22 17:08 aerni