|
@ -69,8 +69,16 @@ class AttributeController extends Controller |
|
|
$model->sort_order = 0; |
|
|
$model->sort_order = 0; |
|
|
$model->cat_id = 0; |
|
|
$model->cat_id = 0; |
|
|
|
|
|
|
|
|
if ($model->load(Yii::$app->request->post()) && $model->save()) { |
|
|
|
|
|
return $this->redirect('index'); |
|
|
|
|
|
|
|
|
if ($model->load(Yii::$app->request->post())) { |
|
|
|
|
|
$model->value = str_replace(',', ',', $model->value); |
|
|
|
|
|
$array = explode(',', $model->value); |
|
|
|
|
|
if (count($array) != count(array_unique($array))) { |
|
|
|
|
|
\Yii::$app->getSession()->setFlash('error', '不能有相同的属性值'); |
|
|
|
|
|
return $this->render('create', ['model' => $model]); |
|
|
|
|
|
} |
|
|
|
|
|
if ($model->save()) { |
|
|
|
|
|
return $this->redirect(['index']); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return $this->render('create', [ |
|
|
return $this->render('create', [ |
|
@ -89,7 +97,16 @@ class AttributeController extends Controller |
|
|
{ |
|
|
{ |
|
|
$model = $this->findModel($id); |
|
|
$model = $this->findModel($id); |
|
|
|
|
|
|
|
|
if ($model->load(Yii::$app->request->post()) && $model->save()) { |
|
|
|
|
|
|
|
|
if ($model->load(Yii::$app->request->post())) { |
|
|
|
|
|
$model->value = str_replace(',', ',', $model->value); |
|
|
|
|
|
$array = explode(',', $model->value); |
|
|
|
|
|
if (count($array) != count(array_unique($array))) { |
|
|
|
|
|
\Yii::$app->getSession()->setFlash('error', '不能有相同的属性值'); |
|
|
|
|
|
return $this->render('create', ['model' => $model]); |
|
|
|
|
|
} |
|
|
|
|
|
if ($model->save()) { |
|
|
|
|
|
return $this->redirect(['index']); |
|
|
|
|
|
} |
|
|
return $this->redirect('index'); |
|
|
return $this->redirect('index'); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|