2amigos / yii2-selectize-widget

Selectize From Brian Reavis Yii2 Widget
Other
73 stars 41 forks source link

SelectizeTextInput does not show previous selected tags #21

Closed Karadox closed 7 years ago

Karadox commented 9 years ago

Just updated to latest version and changed from Selectize to SelectizeTextInput. But now when i add tags and want to edit them, they don't show up in the textinput.

They are saved and linked. When i do an implode to convert the array to a string, and put in the options array, the tags are displayed only the selectize filter doesn't work properly and only the first tag is not visible in the ddlb.

Could you enlighten me with the correct way so they are editable? Maybe an example to use it as a widget in activeform? Or this an actual bug and it isn't possible right now?

Code: _form.php:

<?= $form->field($model, 'extensionNames')->widget(SelectizeTextInput::className(), [
    'loadUrl' => ['extensions/list'],
    'options' => ['class' => 'form-control'],
    'clientOptions' => [
        'plugins' => ['remove_button'],
        'valueField' => 'name',
        'labelField' => 'name',
        'searchField' => ['name'],
        'create' => true,
    ],
])->hint('Use commas to separate tags') ?>
sanjarbek commented 9 years ago

The same problem.

ghost commented 9 years ago

Idem

tonydspaniard commented 8 years ago

@Karadox apologies for huge delay. checking.

tonydspaniard commented 8 years ago

@Karadox I have tried to replicate your issue but is working on my end:

<?= $form->field($model, 'zip')->widget(
    SelectizeTextInput::className(),
    [
        'options' => ['class' => 'form-control'],
        'clientOptions' =>
            [
                'plugins' => ['remove_button'],
                'create' => true,
                'delimiter' => ',',
                'persist' => false,
                'createOnBlur' => true
            ]
    ]
)->hint('Use commas to delimit zip codes') ?>

The model, does have the 'zip' as a string but i could easily enhance this with the taggable behavior for example where i can store linked tag items. The only thing to do is to add a new virtual property ('tagNames'), make sure its set as 'safe' in rules and thats it. I cannot replicate your issue. Can any of you guys show me more code of your issue?