# Checkbox ticked with conditions

**URL:** <https://community.silverfin.com/t/checkbox-ticked-with-conditions/2468>\
**Category:** Templates\
**Tags:** input\
**Created:** [November 17, 2023, 2:06pm UTC](https://community.silverfin.com/t/checkbox-ticked-with-conditions/2468 "2023-11-17T14:06:40Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![JonathanK](https://avatars.discourse-cdn.com/v4/letter/j/9fc348/32.png) [@JonathanK](https://community.silverfin.com/u/JonathanK)\
**Post date:** [November 17, 2023, 2:06pm UTC](https://community.silverfin.com/t/checkbox-ticked-with-conditions/2468/1 "2023-11-17T14:06:40Z")

</div>

Hi All,

I’m currently trying to implement in one of our template a checkbox that will be automatically ticked under certain conditions (See below my current coding)

{% if company.company\_form == “sa” or company.company\_form == “sca” or company.company\_form contains ‘commandite par actions’ or company.company\_form contains ‘anonyme’%}  
{% assign custom.is.optioncapital == true %}  
{% else %}  
{% assign custom.is.optioncapital == false %}

\*NB: I’m only a rookie in the liquid world so don’t be hard with my initial coding 🙂

However, while using such code the checkbox remain unticked even if the company form criteria is true.

Do you have any idea how to resolve such issue?

Thanks

Jon

---

<div class="post-metadata">

**Author:** ![Michiel](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.silverfin.com/michiel/32/2364_2.png) [@Michiel](https://community.silverfin.com/u/Michiel)\
**Post date:** [November 21, 2023, 8:35am UTC](https://community.silverfin.com/t/checkbox-ticked-with-conditions/2468/2 "2023-11-21T08:35:15Z")

</div>

Hi @JonathanK

Thank you for reaching out! Input variables can never be filled by an [assign statement](https://developer.silverfin.com/docs/assign). This statement is exclusively designed for local variables.

Instead, consider leveraging this condition to establish a default value for your input. Remark that [default values](https://developer.silverfin.com/docs/input-fields-attributes-placeholder-default-assign) are not stored in the database though!

Your code could look like this:

```auto
{% if company.company_form == “sa” or company.company_form == “sca” or company.company_form contains ‘commandite par actions’ or company.company_form contains "anonyme" %}
  {% assign default_optioncapital == true %}
{% else %}
  {% assign default_optioncapital == false %}
{% endif %}  

{% input custom.is.optioncapital as:boolean default:default_optioncapital %}

```

Have a nice day,

Michiel

---

<div class="post-metadata">

**Author:** ![JonathanK](https://avatars.discourse-cdn.com/v4/letter/j/9fc348/32.png) [@JonathanK](https://community.silverfin.com/u/JonathanK)\
**Post date:** [November 21, 2023, 11:11am UTC](https://community.silverfin.com/t/checkbox-ticked-with-conditions/2468/3 "2023-11-21T11:11:26Z")

</div>

Hi Michiel,

Thanks for your advice unfortunately it does not resolve my issue and does not create an automatically checked checkbox…

I tried therefore to apply another option with a Yes/No default value that works properly (See below)

{% if company.company\_form == “sa” or company.company\_form == “sca” or company.company\_form contains ‘commandite par actions’ or company.company\_form contains ‘anonyme’%}

**{% t “capital” %}** {% input custom.is.optioncapital as:select options:optioncapital default:“Yes” %}  
{% else %}  
**{% t “capital” %}** {% input custom.is.optioncapital as:select options:optioncapital default:“No” %}  
{% endif %}

{% result ‘is\_capital’ custom.is.optioncapital %}

However, now while trying to look for the result in another template the default value shows a blank result whereas if I update manually the default selection the result return the correct value.

Do you have any view why my default value does not give the appropriate result?

---

<div class="post-metadata">

**Author:** ![Michiel](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.silverfin.com/michiel/32/2364_2.png) [@Michiel](https://community.silverfin.com/u/Michiel)\
**Post date:** [November 21, 2023, 12:14pm UTC](https://community.silverfin.com/t/checkbox-ticked-with-conditions/2468/4 "2023-11-21T12:14:21Z")

</div>

Hi @JonathanK ,

the following boolean input variables will work. As mentioned previously, default values will not lead to a database entry, therefor the custom variable will still be blank. Remark that I added an assign statement within the input statement to resolve this. You can find more details on that attribute [here](https://developer.silverfin.com/docs/input-fields-attributes-placeholder-default-assign).

```auto
{% if company.company_form == “sa” or company.company_form == “sca” or company.company_form contains ‘commandite par actions’ or company.company_form contains "anonyme" %}
  {% t "capital" %} {% input custom.is.optioncapital as:boolean default:true assign:optioncapital %}
{% else %}
  {% t "capital" %} {% input custom.is.optioncapital as:boolean default:false assign:optioncapital %}
{% endif %}

{% result "is_capital" optioncapital %}

```

Kind regards,  
Michiel

---

<div class="post-metadata">

**Author:** ![JonathanK](https://avatars.discourse-cdn.com/v4/letter/j/9fc348/32.png) [@JonathanK](https://community.silverfin.com/u/JonathanK)\
**Post date:** [November 21, 2023, 12:54pm UTC](https://community.silverfin.com/t/checkbox-ticked-with-conditions/2468/5 "2023-11-21T12:54:48Z")

</div>

Hi Michiel,

Many thanks for your answer I finally get your point 🙂 the code is working properly and resolve my issues.

Many thanks for this!

Kind regards,

Jonathan
