<?php
use yii\helpers\Url;
use home\assets\MainAsset;
use yii\helpers\ArrayHelper;
use common\api\User;
use home\assets\LinkAsset;
use home\assets\ModalAsset;
use common\assets\ArtDialogAsset;

LinkAsset::register($this);
$this->title = '添加区域';

$assetUrl = $this->getAssetManager()->getBundle(ModalAsset::className())->baseUrl;
$this->registerJsFile($assetUrl . '/js/district.link.js', ['depends' => [ModalAsset::className(), ArtDialogAsset::className()]]);

//默认值
if ($model->isNewRecord) {
	$model->sort = 0;
	$model->status = 1;
    if (Yii::$app->request->get('id') != '') {
		$model->parent_id = Yii::$app->request->get('id');
	}
} else {
	if (!empty($model['district'])){
		$model->num = count($model['district']);
	}
}
?>
<div class="modal-window">
    <?= \home\widgets\Alert::widget(); ?>
    <?= $this->render('_form', ['model' => $model, 'action' => $action]); ?>
</div>
<script>
	var projectParams = {
		selectDistrictUrl : "<?= Url::to(['select-district']) ?>",
		cityUrl : "<?= Url::to(['district-city']) ?>",
		areaUrl : "<?= Url::to(['district-area']) ?>",
		dateType : "0"
	}
</script>