|
|
@@ -18,7 +18,7 @@ class ArticleForm extends Model
|
|
|
public $cid;
|
|
|
public $sort;
|
|
|
public $content;
|
|
|
- public $countries;
|
|
|
+ public $countryId;
|
|
|
|
|
|
/**
|
|
|
* @inheritdoc
|
|
|
@@ -27,8 +27,8 @@ class ArticleForm extends Model
|
|
|
{
|
|
|
return [
|
|
|
[['id', 'title', 'cid', 'content'], 'trim'],
|
|
|
- [['id', 'title', 'cid', 'content', 'countries'], 'required'],
|
|
|
- [['countries'], 'string'],
|
|
|
+ [['id', 'title', 'cid', 'content', 'countryId'], 'required'],
|
|
|
+ [['countryId'], 'string'],
|
|
|
[['id'], 'exist', 'targetClass'=>Article::class, 'targetAttribute'=>'ID'],
|
|
|
[['cid'], 'exist', 'targetClass'=>ArticleCategory::class, 'targetAttribute'=>'ID'],
|
|
|
];
|
|
|
@@ -42,7 +42,7 @@ class ArticleForm extends Model
|
|
|
'cid' => 'Type', // 分类
|
|
|
'content' => 'Content', // 内容
|
|
|
'sort' => 'Sort', // 排序
|
|
|
- 'countries' => 'Country', // 国家
|
|
|
+ 'countryId' => 'Country', // 国家
|
|
|
];
|
|
|
}
|
|
|
|
|
|
@@ -54,8 +54,8 @@ class ArticleForm extends Model
|
|
|
{
|
|
|
$parentScenarios = parent::scenarios();
|
|
|
$customScenarios = [
|
|
|
- 'add' => ['title', 'cid', 'content', 'sort', 'countries'],
|
|
|
- 'edit' => ['id','title', 'cid', 'content', 'sort', 'countries'],
|
|
|
+ 'add' => ['title', 'cid', 'content', 'sort', 'countryId'],
|
|
|
+ 'edit' => ['id','title', 'cid', 'content', 'sort', 'countryId'],
|
|
|
'sort' => ['id', 'sort'],
|
|
|
];
|
|
|
return array_merge($parentScenarios, $customScenarios);
|
|
|
@@ -91,7 +91,7 @@ class ArticleForm extends Model
|
|
|
$model->CONTENT = '';
|
|
|
$model->STATUS = 1;
|
|
|
$model->SORT = $this->sort;
|
|
|
- $model->COUNTRY_ID = $this->countries;
|
|
|
+ $model->COUNTRY_ID = $this->countryId;
|
|
|
if(!$model->save()){
|
|
|
throw new Exception(Form::formatErrorsForApi($model->getErrors()));
|
|
|
}
|