private function getParentGroups($groupId = '')
 {
     $groups = $_dataMap = [];
     if (!$groupId) {
         $groupId = $this->Id;
     }
     $_dataMap = ArrayHelper::map(Group::find()->where(['status' => '1'])->andWhere('Id <=' . $groupId)->all(), 'Id', 'parentId');
     $groups[] = $key = $groupId;
     while ($key != 0) {
         if (isset($_dataMap[$key]) && $_dataMap[$key] != 0) {
             $groups[] = $key = $_dataMap[$key];
         } else {
             $key = 0;
         }
     }
     return $groups;
 }
use yii\helpers\Html;
use yii\widgets\ActiveForm;
use yii\helpers\ArrayHelper;
/**
 * @var yii\web\View $this
 * @var common\models\User $model
 * @var yii\widgets\ActiveForm $form
 */
//print_r($model->groupMap);
?>
<div class="user-form">
    <?php 
$form = ActiveForm::begin();
?>
    <?php 
echo $form->field($model, 'groupMap')->checkboxList(ArrayHelper::map(\mithun\usermanage\models\Group::find()->where(['status' => '1'])->all(), 'Id', 'name'), ['class' => 'list-group', 'itemOptions' => ['class' => 'list-group-item']]);
?>

    <div class="form-group">
        <?php 
echo Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
?>
        <?php 
echo Html::button('Back', ['class' => 'btn btn-default', 'onclick' => 'history.go(-1);return true;']);
?>
    </div>
    <?php 
ActiveForm::end();
?>
</div>
Ejemplo n.º 3
0
?>

    <?php 
echo $form->field($model, 'firstname')->textInput(['maxlength' => 45]);
?>

    <?php 
echo $form->field($model, 'lastname')->textInput(['maxlength' => 45]);
?>

    <?php 
echo $form->field($model, 'phone')->textInput(['maxlength' => 10]);
?>
    
    <?php 
echo $form->field($model, 'groupId')->dropDownList(ArrayHelper::merge(["Select" => 'Select'], ArrayHelper::map(\mithun\usermanage\models\Group::find()->where(['status' => '1'])->all(), 'Id', 'name')));
?>

    <div class="form-group">
        <?php 
echo Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
?>
        <?php 
echo Html::button('Back', ['class' => 'btn btn-default', 'onclick' => 'history.go(-1);return true;']);
?>
    </div>

    <?php 
ActiveForm::end();
?>