Skip to content

Cross Blueprint Field conditions #10756

Answered by robdekort
fighter3005 asked this question in Q&A
Discussion options

You must be logged in to vote

In the boot method of your Service Provider you could do something like this:

View::composer('statamic::layout', function ($view) {
    if (auth()->guest()) {
        return;
    }

    Statamic::provideToScript([
        'my_custom_config' => GlobalSet::findByHandle('my_global_handle')->inDefaultSite()->get('my_global_field'),
    ]);
});

Then in cp.js:

Statamic.booting(() => {
    Statamic.$conditions.add('my_custom_condition', () => {
        if (StatamicConfig.my_custom_config) {
            return true;
        }
    });
});

And then in your fieldset yaml:

if:
  label: 'custom my_custom_condition'

https://statamic.dev/conditional-fields#custom-logic

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@robdekort
Comment options

Answer selected by fighter3005
@fighter3005
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants