How can I make a field conditionally required in bonzai version?

  • 1
  • Question
  • Updated 3 years ago
  • Answered
Hi I have 3 fields. I need to require at least one of them having a value. How should I do this? I tried the field renderer, but that made the field read only?
Photo of Janet

Janet

  • 486 Points 250 badge 2x thumb

Posted 3 years ago

  • 1
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,714 Points 20k badge 2x thumb
Conditionally render two fields. One required and one not required.
Photo of Janet

Janet

  • 486 Points 250 badge 2x thumb
I want to show all 3 fields at all times though.
Field 1: not required.
Field 2: required. render condition: field 2 is null
Field 3: not required. render condition: field 1 and 2 is null?

What would be the right set up? Thanks!
Photo of Janet

Janet

  • 486 Points 250 badge 2x thumb
Can I use action on Model to achieve this? I'm new to Skuid. Can you provide a snippet that does that for 2 fields maybe for demo?
Photo of GMan

GMan

  • 72 Points
Hey Pat, very clever fix. Just create a duplicate set of fields with one set being set as required in Skuid and the others not and then set your rendering conditions accordingly. I had the same issue with just needing 1 field required but still render the rest of the fields as optional.
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,714 Points 20k badge 2x thumb
Sorry. I've got to pass the baton. My own work is pressing. :S
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
I haven't tested this, but you could try enable conditions on fields 2 and 3 instead of render conditions. That way they would be visible, but not editable unless the condition was met.
Photo of Janet

Janet

  • 486 Points 250 badge 2x thumb
Thanks! I will actually need to have them editable at all times. So I did this by running validations in javascript. The element.html() was causing the trouble.
Photo of GMan

GMan

  • 72 Points
Hi J!  Did you ever implement your solution in JS and if so, would mind sharing it?  Thanks!