Home > Forum > Forms > Required boolean field

Required boolean field
0

MVP

Hi,

I'm wondering if I missed something or there's another/bezter way to add a required boolean field.

My current approach is to define a choice field with true/false options, set a label "select an option" and mark this field as required. I'm using global constants for the IDs so that I can check the value of necessary.

I don't use the boolean field itself because an unchecked boolean field would fulfill the required definition too, if I remember correctly,

Is there a better way?

It just came to my mind that I could create a form field extensions for a boolean field to provide a drop-down instead of checkbox. On the other side I'm not even sure that I can define a form for extension for a boolean field.

Best regards,
Daniel

MVP
In reply to: Christian Amler

Hi Daniel,

I never used it myself, but maybe the field type choice list with the options Yes/No would be worth looking into there.

Cheers
Chris

Hi Christian,

thanks for the input. I'm forgetting this field type often myself. :)
I had a short look but doesn't seem promising. No option for multilingual values and I'm not sure that I can easily use the selected true/false value in some condition.

If I have time I will look into creating an formfieldJS extension. Since I can't use this for boolean fields I could use an integer field. At least the stored values would be similar to a boolean field.


Best regards,
Daniel

MVP
In reply to: Christian Amler

Hi Daniel,

indeed. I added one to my sample process yesterday, and saw that it is actually not of much use for the reasons you named. So good luck with your approach.

I had a similar problem and used dropdown with fixed list values yes & no.

It would be nice if you could share your solution once you're done! :)

Cheers, Chris

Hi Chris,

I just wanted to start with it and noticed that it won't be possible:

Field Types which support FormFieldExtensionJS

Basic form fields
- Single line of text
- Multiple lines of text
- Floating point number
Picker fields
- Date time

So benefit of creating an form field extension for an integer field would have been that no type conversion would have been necessary. The values 0 and 1 would have matched the values of the boolean field itself. Using floating point number fields or text fields would require a conversion. In this case it makes no difference and I will stick to my current approach.

Regards,
Daniel