<?php
use yii\helpers\Url;
use home\assets\LinkAsset;
use home\modules\customer\models\Customer;

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

$this->title = '添加联系人';
LinkAsset::register($this);

//默认值
if ($model->isNewRecord) {
	$model->sort = 0;
	$model->status = 1;
    $customer_no = Yii::$app->request->get('customer_no');
    if (!empty($customer_no)) {
        $contract = Customer::find()->select('name')->where(['customer_no' => $customer_no])->one();
        $model->customer_no = $customer_no;
        $model->customer_name = $contract->name;
    }

} else {
    $model->customer_name = isset($model['customer']['name']) ? $model['customer']['name'] : '';
}
?>
<div class="modal-window">
    <?= \home\widgets\Alert::widget(); ?>
    <?= $this->render('_form', ['model' => $model, 'action' => $action]); ?>
</div>