<p>Reply via Brandon:</p>

<p>A single field does probably make more sense here, as you have it.</p>

<p>You're close to getting it working, but your syntax for filtering categories based on craft.locale is wrong. Checkboxes fields store the selected option values as JSON, so if you check your craft_content table you will find values like</p>

<p><code>["option_1","option_2","option_3"]</code></p>

<p>When you do this:</p>

<p><code>.regionAvailability(craft.locale)</code></p>

<p>it is looking for a row where the <code>regionAvailability</code> value is equal to <code>craft.locale</code>. Even if only a single locale is checked, its value would still be <code>["locale_id"]</code>, not just <code>locale_id</code>.</p>

<p>So to fix this just change that parameter to:</p>

<p><code>.regionAvailability('*"'~craft.locale~'"*')</code></p>

<p>or</p>

<p><code>.regionAvailability("*\"#{craft.locale}\"*")</code></p>

<p>(both do the same thing; just pick the one you think is more clear)</p>

CC BY-SA 3.0
2016-08-23T11:36:44.327Z
2016-08-23T11:36:44.327Z
Rob Hodges
<p>I had what I thought was a very simple issue: Select some categories on the front-end, filtering by a Checkbox field.</p>

<p>The Checkbox has values, which correlate to Locales.</p>

<p>The end goal was to create a 'workaround' to the fact that you can't disable/enable a category per Locale.</p>

<p>So on the template, I attempted:</p>

<pre><code>{% for collection in craft.categories.group('dressCollection').regionAvailability(craft.locale) %}
</code></pre>

<p>But that doesn't work.</p>

<categories><localization><checkboxes>
Selecting entries using a checkbox field
# Selecting entries using a checkbox field

(Asked by: username_0 on 2016-08-23)

I had what I thought was a very simple issue: Select some categories on the front-end, filtering by a Checkbox field.
The Checkbox has values, which correlate to Locales.
The end goal was to create a 'workaround' to the fact that you can't disable/enable a category per Locale.
So on the template, I attempted:
{% for collection in craft.categories.group('dressCollection').regionAvailability(craft.locale) %}

But that doesn't work.

**Tags:** categories, localization, checkboxes


---

## 1 answers

### Answer by username_0 on 2016-08-23. Score: 2

Reply via Brandon:

A single field does probably make more sense here, as you have it.

You're close to getting it working, but your syntax for filtering categories based on craft.locale is wrong. Checkboxes fields store the selected option values as JSON, so if you check your craft\_content table you will find values like

`["option_1","option_2","option_3"]`

When you do this:

`.regionAvailability(craft.locale)`

it is looking for a row where the `regionAvailability` value is equal to `craft.locale`. Even if only a single locale is checked, its value would still be `["locale_id"]`, not just `locale_id`.

So to fix this just change that parameter to:

`.regionAvailability('*"'~craft.locale~'"*')`

or

`.regionAvailability("*\"#{craft.locale}\"*")`

(both do the same thing; just pick the one you think is more clear)


---

