Conditionals on Block Attributes

Hi!

Would it be possible to add conditional logic to the block attributes?

So for example i have 2 block attributes. Block Attribute 1 and Block Attribute 2.

I want to show Block Attribute 2 if Block Attribute 1 is not empty or if Block Attribute 1 has a certain value/text.

Would that be easy to implement? That would be really powerful and make it a lot cleaner if i have a lot of attributes.

@matjaz @TechAkayy

Thanks
Guido

7 Likes

I am new to Pinegrow and was wondering about the exact same question.

2 Likes

Hi @matjaz

Just wanted to follow up on this plus an add-on question :wink:

I just noticed that i can only add 12 attributes to a block. Can this number be increased or is this an limitation on Gutenberg Blocks and the amount of attributes they hold?

Thanks
Guido

1 Like

Another follow up @matjaz :slightly_smiling_face:

Any insight into this?

Thanks
Guido

This is just a PG limit. I increased it to 24 now. There is some performance hit if there are many fields, so don’t want to go too high for this.

1 Like

Hi @matjaz

Oke great! Don’t think i will ever need to go above 24. But super helpful that i can add more then 12 in the next release.

Could you also please respond to my initial question about the conditionals on block attributes? That is something i really hope that is possible. Especially if i ever have to go to 24 attributes then showing them conditionally would be awesome! :wink:

Thanks @matjaz

Guido

Yes, conditionals would be great. Not just based on attribute values, but also on user roles / capabilities. That would let us make certain attributes editable only to specified users. I’m thinking about how to implement this in an elegant way.

4 Likes

@matjaz AWESOME!! That is really good news! :wink: Cant wait to play around with that. :smiley:

Guido

Hi @matjaz

I just received this update from metabox: MB Blocks Update: Register Block Using block.json File - Meta Box

Is this something that Pinegrow is already doing while registering blocks? Just thought i would share it with you since it might make it easier to register settings and attributes? Or might make it easier to have more attributes/have conditionals?

Guido