<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
use qcbase\models\Menu;
use yii\db\Query;
use yii\helpers\Url;

/* @var $this yii\web\View */

$form = ActiveForm::begin([
        'id' => 'main-form',
        'action' => ($model -> isNewRecord) ? ['role/create'] : ['role/update'],
        'fieldConfig' => [
            'options' => ['tag' => 'tr'],
            'template' => "<th width='120'>{label}</th><td>{input}{hint}{error}</td>",
        ]
    ]);
?>

<div class="h_a">基本属性</div>
<div class="table_full">
    <table width="100%">

        <?= $form->field($model, 'name')->textInput(['class' => 'input length_5', 'placeholder' => '']); ?>

        <tr>
            <th width='120'>上级角色<span class="redstar">*</span></th><td><?= Html::dropDownList('parent', (isset($parent['parent'])) ? $parent['parent'] : '', \qcbase\models\Auth::getDropDownRoleList(true)); ?></td>
        </tr>

        <?php if ($model->isNewRecord) : ?>
        <tr>
            <th width='120'>复制角色权限</th><td><?= Html::dropDownList('copy_role', '', \qcbase\models\Auth::getDropDownRoleList(true)); ?></td>
        </tr>
        <?php endif; ?>

        <?= $form->field($model, 'description')->textarea(['class' => 'textarea_code', 'placeholder' => '']); ?>

    </table>
</div>

<?php 
if (!$model->isNewRecord) {
    echo Html::hiddenInput('id', $model->name);
    echo Html::hiddenInput('old_parent', isset($parent['parent']) ? $parent['parent'] : '');
    echo Html::hiddenInput('old_role', isset($model['name']) ? $model['name'] : '');
}
?>

<div class="btn_wrap">
    <div class="btn_wrap_pd">
        <?= Html::submitButton('提交', ['class' => 'btn btn_submit mr10']); ?>
    </div>
</div>
<?php ActiveForm::end(); ?>
