Feature Request: Conditional Attributes and Conditional Remove for Block Creator

Hello,

I’ve really been enjoying the PG Gutenberg block creator. It’s great for simple blocks! One thing that would really take it to the next level for me is if I could:

  1. Hide one or more attributes depending on the value of another attribute. For example, if I have an “Active Toggle” attribute set to true then I want to show the URL attribute and maybe the icon attribute but if it’s not ticked to true then those are not used and therefore not shown in the UI.
  2. Remove one or more attributes from the front end depending on the value of another attribute. Similar to how the remove element works now but based on other attributes values, not just the value of its own attribute.

Thanks! Keep up the great work… PG has come so far in the last year :star_struck:

Thanks @jonroc!

#1 is added to the to-do list.

#2 this can be done already.

Imagine this layout:

section
    label
    h1
    ...

section has the Block attribute “display_label_and_h1” with Toggle, and Use as None.

On both label and h1 elements add the same attribute “display_label_and_h1”, Use as None and Remove if not defined. It doesn’t matter what Name and Control type you set because the attribute was already defined on Section and that (the first) definition will be used.

This should hide both the label and h1 if the toggle is inactive.

1 Like

Ok, cool.

One more small thing. If no background image is selected for the background image attribute then it would be helpful if the style did not get added vs. adding it with url(unknown). Forcing an unknown url is making it so I can’t use a gradient color on the block when there is no background image. -Thanks