我想为我的更新页面设置可标记的默认值,但我做不到!
这是我在_form.php
.
https://github.com/2amigos/yii2-taggable-behavior
<?=
$form->field($model, 'tags')->widget(SelectizeTextInput::className(), [
// calls an action that returns a JSON object with matched
// tags
'loadUrl' => ['tags/list'],
'options' => ['class' => 'form-control'],
'clientOptions' => [
'plugins' => ['remove_button'],
'valueField' => 'name',
'labelField' => 'name',
'searchField' => ['name'],
'create' => true,
],
])->hint('Use commas to separate tags')
?>
这是我的模型:
class Post extends \yii\db\ActiveRecord
{
public $category;
public $prime;
public $metaNames;
public $metaDec;
public $tags;
/**
* @inheritdoc
*/
public static function tableName()
{
return 'post';
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['menu', 'prime', 'slideshow', 'special', 'visit', 'deleted', 'active'], 'integer'],
[['name', 'summary', 'text', 'sutitr', 'reference', 'slug', 'menu', 'slideshow', 'special', 'visit', 'created', 'modified', 'deleted', 'active'], 'required'],
[['summary', 'tagDec', 'metaDec', 'tags', 'text', 'sutitr'], 'string'],
[['created', 'modified'], 'safe'],
['category', 'each', 'rule' => ['integer']],
[['tagNames'], 'safe'],
[['headline'], 'string', 'max' => 255],
[['name', 'reference'], 'string', 'max' => 100],
[['slug'], 'string', 'max' => 200],
[['user_id'], 'exist', 'skipOnError' => true, 'targetClass' => User::className(), 'targetAttribute' => ['user_id' => 'id']],
];
}
我想在更新页面中设置默认标签。