Either two validators with OR operator or hiding one field

Hello,

I have a structure field with two fields (field A and field B). Both fields have one validator but they don’t share the same validator. Depending on a toggle, either field A or field B is shown when creating a new entry in the structure. The structure field itself shows all fields. How can I do either

  1. combine both fields to one field so it has an or validator active: either text or URL,
  2. hide one of both fields depending on the when property which is depend on the trigger?

My current issue is that not both fields should show and that I’m not aware how I can combine both fields so I can’t realize option 1 and option 2.

Best Regards,

Hm, it’s probably too late and my brain doesn’t work. Could you please post your blueprint?

It’s about this issue: https://github.com/getkirby/kirby/issues/1950#issue-473553964

I want to optimize the shown columns of the structure and hide unnecessary fields/information: If the source is an URL, it can’t be a book/whatever and vice versa.

Apart from the toggle issue, if you use a checkbox field instead of the toggle, does it work then?

I think this is not too close tied to the issue I reported. In fact, I just don’t know how I can assign two validators to a field so the field’s input becomes valid if one of the two validators pass or how I can hide columns in the structure if the field is hidden on inserting an entry due to the when condition. I don’t see how a checkbox instead of the toggle helps here.

Hm, maybe with some regex voodoo, but that would be beyond my knowledge, I’m afraid. Or conditions should be possible in regex.

As regards hiding columns, not just fields or sections, I don’t think that’s possible.

Ah, I didn’t remember that I can add a regular expression to a field as validation and then just leave out the two Kirby 3 validators. This is fine in my case as it shouldn’t be too hard to combine both validators in one regex.

Can you agree that this scenario makes sense like that I don’t do a complex setup for something I should simplify? If you agree, I will create a feature request issue on Github.

Hm, I don’t understand what the issue is? What has this got to do with columns?

As I said, my brain is failing me tonight and I will go to sleep now. to be awake in time for the climate strike tomorrow Feel free to create an ideas issue no matter if I understand your problem or not.

1 Like

Have a nice day tomorrow, glad to see you there!

The issue with the columns is that I see two columns (for field A and B) although only one of these two fields is filled in when an entry is added to the structure. This is due to the when condition which is based on the toggle so both fields can’t be filled in nor should be shown in the column list of the structure. I will create an issue for this tomorrow.

Thank you!