$names = [
'stats' =>'Статистика',
'chat' =>'Общение',
'host'=>'Домен и хостинг',
'other'=>'Другое',
];
<?php foreach ($checks as $key => $check): ?>
<div class="carousel-item">
<a class="go-step position-absolute" data-step="1" href="#">Вернуться назад</a>
<h2 class="color-primary"><?=$names[$key] ?></h2>
<?= $form->field($model, $key)->checkboxList($check, [
'class'=>'togglebutton'
])->label(false) ?>
</div>
<?php endforeach; ?>
<?php
namespace app\modules\copy\forms;
use Yii;
use yii\base\Model;
use app\modules\main\Module;
/**
* ContactForm is the model behind the contact form.
*/
class HeaderForm extends Model
{
public $email;
public $site;
public $chat;
public $host;
public $stats;
public $other;
/**
* @return array the validation rules.
*/
public function rules()
{
return [
['stats', 'each', 'rule' => ['safe']],
['stats', 'each', 'rule' => ['default', 'value'=>0]],
['chat', 'each', 'rule' => ['safe']],
['chat', 'each', 'rule' => ['default', 'value'=>0]],
['host', 'each', 'rule' => ['safe']],
['host', 'each', 'rule' => ['default', 'value'=>0]],
['other', 'each', 'rule' => ['safe']],
['other', 'each', 'rule' => ['default', 'value'=>0]],
// name, email, subject and body are required
[['site', 'email'], 'required'],
// email has to be a valid email address
['email', 'email'],
['site', 'string']
];
}