I’m having trouble finding the best way to do this.
I have 3 not required text fields in my blueprint and I would like one of the fields to become required if an other one has content in it.
Field 1: Caption
Field 2: Caption Link
Field 3: Caption Link Title
Let’s say Field 2 gets www.google.com as input, then Field 3 should be required, so the user must fill a title for the URL from field 2.
What would be the best way to do something like this?
The output I’m chasing is:
Field 1 + <a href="Field 2">Field 3</a>
Hm, good question. I think you need a custom field for this that checks if the Caption link is filled in and then adds a required attribute to the title.
I first thought you could use the toggle field, but that doesn’t work with required fields either.
However, I’d probably use a help text (maybe in combination with the toggle field to stress it a bit more that these fields belong together) and then use a fallback text in case the user didn’t fill in the field.
I went for the help instruction, also made it that it wouldn’t render unless there’s a title filled in.
Was looking at Statamic fieldsets and they have this cool thing:
an_other_field_name: not null
As I said, you could create a custom field.