K
K
kranopodem2015-04-02 20:03:42
Yii
kranopodem, 2015-04-02 20:03:42

How to display certain values ​​in the Selectize widget in YII2?

I need to make sure that when adding a record, the widget already has ready-made Tags, but how can I add them there? Thanks in advance!
The documentation did not give anything(
Link to the GitHub widget
Link to the plugin site

<?= $form->field($model, 'tagValues')->widget(SelectizeTextInput::className(), [
    // calls an action that returns a JSON object with matched
    // tags
    'options' => ['class' => 'form-control'],
    'clientOptions' => [
        'valueField' => 'tagValues',
        'labelField' => 'tagValues',
        'searchField' => ['tagValues'],
        'items' => ['tagValues'],
        'create' => true,
        
    ],
]);
?>

The list is empty, nothing falls out.
c120028ebe05ed00da4736ce4a149b.png

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Dupliy, 2015-04-10
@booomerang

If you can't use it, look away - demos.krajee.com/widget-details/select2
It might work.

B
brain2xml, 2019-04-02
@brain2xml

'options' => ['class' => 'form-control', 'value'=>'hello,world' ],

<?= $form->field($model, 'tagValues')->widget(SelectizeTextInput::className(), [
                    'loadUrl' => ['tag/list'],
                    'options' => ['class' => 'form-control', 'value'=>'hello,world'],
                    'clientOptions' => [
                        'plugins' => ['remove_button','restore_on_backspace'],
                        'valueField' => 'label',
                        'labelField' => 'label',

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question