Mautic Community Forums

Boolean Field on a Form

I have added two boolean fields into my fields, (want_a_demo and want_a_brochure). I go into the form builder, and I can select a checkbox group, those don’t result in a boolean response. Is there not anything to add the boolean fields to the form? I just want a checkbox at the form that says, send me a brochure and another check box and label that says I want a demo.

I have added two boolean fields into my fields, (want_a_demo and want_a_brochure). I go into the form builder, and I can select a checkbox group, those don’t result in a boolean response. Is there not anything to add the boolean fields to the form? I just want a checkbox at the form that says, send me a brochure and another check box and label that says I want a demo.

I have a similar requirement. Any luck figuring this out?

Any luck with this?

Guys, could you describe a use case why is boolean value important in the checkbox? If it would be a boolean value, how would you handle multiple checkboxes? They can have more than 2 states.

A checkbox is either checked or unchecked, what other state is there?

The use case is, I have a check box on a form with the label, [] I want a demo. If it is checked, yes they want a demo, if it is not, they don’t want one.

You allow a boolean field to be added to the lead fields, what form element would you use to turn that on or off?

If you have one checkbox in the checkbox list field, then yes, it can have 2 values. If you have 2 checkboxes in the checkbox list field, then there are 4 values. So the values cannot be boolean.

I can see you really, really want to use the boolean lead field and you are right it would make sense if it could map the value with a single checkbox form field. Check if there isn’t an issue created for this already:

https://github.com/mautic/mautic/issues?utf8=✓&q=is%3Aissue+is%3Aopen+checkbox

Or create a new one. The best would be if you could even create such functionality and share it with the community, because there is no “You allow…”, there is the community building this software.

As a quick fix, try to map the form checkbox field to a lead text field. It should allow you to do the same thing (conditions, filters) as with a boolean field.

When you associate a radio / checkbox / select with a boolean or select lead field the best behaviour should be Mautic automatic fills the properties tab. In the properties tab for radio / checkbox / select user should set different strings for values and values labels. In dreamland the default value of your radio / checkbox / select is the actual value of the user field, that is the “Default value” in general tab should be something like {leaduser=optin} (if your lead field name is optin), so when user update his data using an update form he can found his default value and change only needed values. But Mautic doesn’t work this way.

Standard use case: user create an optin boolean field and associate it to a radio or checkbox. THE PROBLEM: user can ONLY use 0 and 1 values (and value’s labels) in form building, so the form looks like “Give me the optin: [] 0 [] 1”. Sad. I’ve used 2 workarounds, use the best for you:

  • (best solution) USE RIGHT FIELD TYPE: never use boolean as lead field: use select instead and use the same values you want to see in your form. You can freely use checkbox (only 1 value, “yes”), radio or select. Note: when you use a select field instead of boolean field, you can use more values (that is: yes | no | null); this can help you to track also leads who don’t set any option (null value)
  • HIDE LABEL: you can use your loved boolean field with a checkbox. But only if you don’t need any value near your single checkbox and you can put all the text in the field label (example: “click here to gimme that important optin”). So when you add the checkbox field to your form, in properties tab add only a value, “1”, then in General tab write in “Default value” 0. In attributes tab, in Radio/checkbox label attributes, write style=“text-shadow: none; color: transparent”. In this way you can hide that silly label of 1

I just did it but I am not interested in “no” just yes so I did this

1 Create Custom Field Boolean, default value 0
2 Create Radio button group with one value (Yes - 1)
3 Don’t make it required

Although it’s a fudge it seems to work unless the punter clicks yes and means no!