Boolean default value

Dear,

I created a boolean in form working_docs with the code below.

{% input custom.boolean.provision as:boolean default:‘true’ %}

In another form I want to use the input of this boolean in an if-function and want that my elsif is fullfilled if the boolean is true (default). The problem is that my elsif is only fullfilled if I untich the boolean first and thick it again but not when I do nothing and leave the boolean at its default value.

So it seems that my if-function does not recognise the default value. Does anyone has a solution for my issue?

{% if period.reconciliations.working_docs.custom.boolean.provision != ‘true’ %}

{% elsif period.reconciliations.working_docs.custom.boolean.provision != ‘false’ %}

Thanks

Hello @marnixcoudre

When a boolean is not ticked, the default value will indeed not be saved. The value of the boolean is blank in the case of a default.

This can be solved by integrating this blank value in your if-function. For example (for use in same template):

{% input custom.boolean.provision as:boolean default:'true' %}
{% if custom.boolean.provision == 'true' or custom.boolean.provision == blank %}
{% elsif custom.boolean.provision == 'false' %}
{% endif %}

For your code could you please try with:

{% if period.reconciliations.working_docs.custom.boolean.provision != 'false' or period.reconciliations.working_docs.custom.boolean.provision == blank %}

Please let us know if this does not solve the issue.

Kind regards,

Mathias

1 Like