How to set checked multiple checkboxes?

Hi. First, I see this topic:

But it not work in my case. I have Article and many categories for this article. (hasMany) I want set checkboxes cheked relation from data in db when I edit Article.

In view

<div class="form-group">
{% for category in categories %}
  <div class="checkbox">
      {{ check_field('categories_ids[]', 'value': }} {{category.title}}
  {% endfor %}

In controller i trying to set like this:

$this->tag->setDefault("categories_ids[]", [1, 2]); // error: must be scalar
$this->tag->setDefaults(["categories_ids[]" => [3,4]]); // nothing

What I do wrong?

im afraid you should define a customed tag for that purpose.

follow THIS.