More Example and Screenshot about cockpit V2

Dear Artur,

Can you give more example or screenshot of code what meta and condition can do?

Thanks Artur for your awesome work

1 Like

Let’s say you only want to show a field if the title field is not empty. Then add the following in the condition field:

data.title && data.title.trim()

Docs will be updated soon

2 Likes

Hi Artur, I need to create a repeatable set of fields for a portfolio site, to emulate something similar to Wordpress Gutenberg. I used to do that in Cockpit V1 with a repeater/set combo.

What I need to do now is create a dropdown select at the top with the content type (image, gallery, featured text…). Then I want to hide/show the fields related to that content type. So basically the condition needs to be something like:
data.type='Gallery'

However it is not working. Is there a different way to get the selected field value from the dropdown, or does the syntax needs to be different?

Could really use your help. Thanks!

Hi @tiagorio :wave:

For such use-case Cockpit offers the layout field type (part of Cockpit pro).

Greets
Artur

I’ve used the layout field type in V1, but isn’t exactly what I need for this case. I just want to create a list of content blocks that can easily be re-ordered or removed, without any grid. The grid is to be defined in the frontend code, and the backend user should have no control over that, other than adding or removing blocks.

Anyway, I just need to know how the hide or show a field, based on the dropdown selected option, is that possible?

I finally found the way, it’s:

data.type=='SelectedOption'

Replace the ‘SelectedOption’ by the value written in the dropdown.

And be careful tu use the double equal sign ‘==’, by mistake I used only one and it would set the value of all the Dropdown instances to that, and they would not work.