Basically i have this:

App\Forms\ProviderAccount.php:

public function phaseTwo()
{
    $subcat = categories::findFirstById($this->session->get('catId'))->getSubcategories();

    $total = -1;

    foreach($subcat as $key => $item){
        $check = new Check("subcat[$key]", ['value' => $item->id]);
        $check->setLabel($item->name);
        $this->add($check);
        $total++;
    }

    return $total;

}

App\Controllers\ProviderController.php:

public function servicesAction()
{
    if(!$this->session->has('catId')){
        $this->response->redirect('/provider/welcome');
    }
     $this->view->total = $this->providerForm->phaseTwo();

    if($this->request->isPost() && $this->providerForm->isValid($this->request->getPost())){
        // Todo: redirect.
    }

    $this->view->form = $this->providerForm;
 }

App\Views\Provider\Services.volt:

{% for i in 0..total %}
     <div class="checkbox">
          {% set name = "subcat[" ~ i ~ "]" %}
          {{ form.render(name) }}
          {{ form.label(name) }}
        </div>
   {% endfor %}

First question: is there a better way of populating checkboxes using database data? Also how can i check if at least one checkbox is active?