'每个配件只能对应一个比例!'], [['category_id'], 'exist', 'skipOnError' => true, 'targetClass' => FixCarCategory::className(), 'targetAttribute' => ['category_id' => 'id']], [['category_id','scale'],'required'] ]; } /** * @inheritdoc */ public function attributeLabels() { return [ 'id' => 'ID', 'category_id' => '配件名', 'pid'=>'PID', 'scale' => '比例', 'created_at' => 'Created At', 'updated_at' => 'Updated At', ]; } /** * @return \yii\db\ActiveQuery */ public function getCategory() { return $this->hasOne(FixCarCategory::className(), ['id' => 'category_id']); } }