|
|
@@ -25,7 +25,7 @@ class AdForm extends Model
|
|
|
public $content;
|
|
|
public $sort;
|
|
|
public $status;
|
|
|
- public $countries;
|
|
|
+ public $countryId;
|
|
|
|
|
|
private $_adModel;
|
|
|
|
|
|
@@ -42,8 +42,8 @@ class AdForm extends Model
|
|
|
public function rules()
|
|
|
{
|
|
|
return [
|
|
|
- [['id', 'title', 'image', 'type', 'lid', 'content', 'sort', 'status', 'countries'], 'trim'],
|
|
|
- [['id', 'title', 'image', 'type', 'lid', 'content', 'sort', 'status', 'countries'], 'required'],
|
|
|
+ [['id', 'title', 'image', 'type', 'lid', 'content', 'sort', 'status', 'countryId'], 'trim'],
|
|
|
+ [['id', 'title', 'image', 'type', 'lid', 'content', 'sort', 'status', 'countryId'], 'required'],
|
|
|
// [['image'], 'url'],
|
|
|
[['id'], 'exist', 'targetClass'=>Ad::class, 'targetAttribute'=>'ID'],
|
|
|
[['id'], 'initModel'],
|
|
|
@@ -64,6 +64,7 @@ class AdForm extends Model
|
|
|
'content' => 'External link or article ID', // 链接地址或文章ID
|
|
|
'sort' => 'Order', // 排序
|
|
|
'status' => 'State', // 状态
|
|
|
+ 'countryId' => 'Country', // 国家
|
|
|
];
|
|
|
}
|
|
|
|
|
|
@@ -75,8 +76,8 @@ class AdForm extends Model
|
|
|
{
|
|
|
$parentScenarios = parent::scenarios();
|
|
|
$customScenarios = [
|
|
|
- 'add' => ['title', 'image', 'type', 'lid', 'content'],
|
|
|
- 'edit' => ['id', 'title', 'image', 'type', 'lid', 'content'],
|
|
|
+ 'add' => ['title', 'image', 'type', 'lid', 'content', 'countryId'],
|
|
|
+ 'edit' => ['id', 'title', 'image', 'type', 'lid', 'content', 'countryId'],
|
|
|
'sort' => ['id','sort'],
|
|
|
'status' => ['id','status'],
|
|
|
];
|
|
|
@@ -141,7 +142,7 @@ class AdForm extends Model
|
|
|
$model->TYPE = $this->type;
|
|
|
$model->LID = $this->lid;
|
|
|
$model->CONTENT = $this->content;
|
|
|
- $model->COUNTRIES = $this->countries;
|
|
|
+ $model->COUNTRY_ID = $this->countryId;
|
|
|
$model->STATUS = 1;
|
|
|
if(!$model->save()){
|
|
|
throw new Exception(Form::formatErrorsForApi($model->getErrors()));
|