<?php
use home\assets\MainAsset;
use yii\widgets\ActiveForm;
use yii\helpers\Html;
use yii\helpers\Url;
use home\modules\sale\models\Category;

/* @var $this \yii\web\View */
/* @var $form yii\bootstrap\ActiveForm */
/* @var $model \home\modules\sale\models\Category */

$attrLabels = $model->attributeLabels();
?>

<div class="modal-window">
	<?php $form = ActiveForm::begin([
            'id' => 'main-form',
			'options' => ['class' => 'informationform f14'],
            'action' => $action,
			'fieldConfig' => [
				'options' => ['tag' => 'td'],
				'template' => "{input}{hint}{error}",
				'errorOptions' => ["class" => "error" ]
			]
        ]); 
    ?>

	<table cellpadding="0" cellspacing="10" width="100%">
		<tbody>
			<tr>
				<td align="right" width="80"><?= $model->getAttributeLabel('name') ?>：</td>
				<?= $form->field($model, 'name')->textInput(['class' => 'form-control']) ?>
				<td><span class="redstar">*</span></td>
			</tr>
			<tr>
				<td align="right">父级：</td>
				<td><select class="form-control" name="Category[parent_id]" id="category-parent-id">
						<option value="0" <?php if ($model->parent_id == 0) echo "selected='selected'" ?>>-----顶级阶段-----</option>
                        <?php echo Category::getDropDownTree($model->parent_id, $model->cat_id, $model->isNewRecord, 'cat_id'); ?>
                    </select>
					<div class="error"></div>
				</td>
				<td><span class="redstar">*</span></td>
			</tr>
			<tr>
				<td align="right"><?= $model->getAttributeLabel('sort') ?>：</td>
				<?= $form->field($model, 'sort')->textInput(['class' => 'form-control']) ?>
				<td><span class="redstar"></span></td>
			</tr>
			<tr>
				<td align="right"><?= $model->getAttributeLabel('status') ?>：</td>
				<?php if ((!$model->isNewRecord) && !Category::checkStatus($model->cat_id)) : ?>
					<td><font color="red" style="font-size: 13px;">上级类别已禁用，本级无法修改状态</font></td>
				<?php else : ?>
					<?= $form->field($model, 'status')->radioList(Category::getStatusList(), ['itemOptions' => ['labelOptions' => ['class'=>'radio-inline'] ] ]);?>
				<?php endif; ?>
				<td></td> 
			</tr>
				<tr>
				<td align="right"><?= $model->getAttributeLabel('remark') ?>：</td>
				<?= $form->field($model, 'remark')->textarea(['class' => 'form-control', 'rows' => '5']) ?>
				<td><span class="redstar"></span></td> 
			</tr>
		</tbody>
	</table>
	<?= ($model->isNewRecord)?'':Html::hiddenInput('id' ,$model->cat_id); ?>
	<?php ActiveForm::end(); ?>
</div>
