public function getOtraslevoeSoglashenieRel()
 {
     return $this->hasOne(\app\entities\OtraslevoeSoglashenie::className(), ['id' => 'otraslevoe_soglashenie']);
 }
<?php

use yii\helpers\Html;
use app\enums\TipOtraslevogoSoglashenijya;
$otraslevoeSoglashenie = [];
$tipOtraslevogoSoglasheniya = TipOtraslevogoSoglashenijya::namesMap();
foreach (\app\entities\OtraslevoeSoglashenie::find()->orderBy('tip')->orderBy('nazvanie')->each() as $item) {
    $otraslevoeSoglashenie[$tipOtraslevogoSoglasheniya[$item->tip]][$item->id] = $item->nazvanie;
}
?>
<div class="panel panel-default" id="panelos<?php 
echo $num;
?>
">
    <div class="panel-body">
        <?php 
echo Html::activeHiddenInput($model, "[{$num}]id");
?>
        <?php 
echo Html::activeHiddenInput($model, "[{$num}]zayavlenieNaAttestaciyu");
?>
        <div class="col-md-8 no-right-padding">
            <?php 
echo Html::activeLabel($model, "[{$num}]otraslevoeSoglashenie");
?>
            <?php 
echo \kartik\widgets\Select2::widget(['model' => $model, 'attribute' => "[{$num}]otraslevoeSoglashenie", 'data' => $otraslevoeSoglashenie, 'pluginOptions' => ['width' => '100%']]);
?>
            <?php 
echo Html::tag('div', $model->getFirstError('otraslevoeSoglashenie'), ['class' => 'help-block']);
?>