例外' yii \ base \ UnknownPropertyException'消息'获取未知属性:common \ models \ Spot :: sportsValues'在D:\ Programs \ xampp \ htdocs \ frost \ vendor \ yiisoft \ yii2 \ base \ Component.php:143堆栈跟踪:
spot> _form文件
use dosamigos\selectize\SelectizeTextInput;
<?= $form->field($model, 'sportsValues')->widget(SelectizeTextInput::className(), [
'loadUrl' => ['/sports/sports/list'],
'options' => ['class' => 'form-control'],
'clientOptions' => [
'plugins' => ['remove_button'],
'valueField' => 'name',
'labelField' => 'name',
'searchField' => ['name'],
'create' => false,
],
]) ;
?>
专题模型
use creocoder\taggable\TaggableBehavior;
public function behaviors()
{
return [
TaggableBehavior::className(),
];
}
/**
* @inheritdoc
*/
public function rules()
{
return [
['sportsValues', 'safe'],
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'sportsValues' => Yii::t('common', 'Sports'),
];
}
public function getSports()
{
return $this->hasMany(Sports::className(), ['id' => 'sports_id'])->viaTable('{{%sports_spot}}', ['spot_id' => 'id']);
}
public function getSportsLinks()
{
$sportsLinks = [];
foreach ($this->sports as $sports) {
$sportsLinks[] = Html::a($sports->name, ['sports', 'slug' => $sport->name]);
}
return implode(', ', $sportsLinks);
}
public static function find()
{
return new SpotQuery(get_called_class());
}
`
SpotQuery
public function behaviors()
{
return [
TaggableQueryBehavior::className(),
];
}