Open Dunc80 opened 6 years ago
Hi,
just had the same question:
Example:
use app\models\DbTable;
echo SelectizeTextInput::widget([
'name' => 'tagsGlobal',
'value' => '162,163', // <----------------- Thats the IDs
'loadUrl' => ['tag/listglobal2'],
'clientOptions' => [
'plugins' => ['remove_button'],
'valueField' => 'id',
'labelField' => 'name',
'searchField' => ['name'],
'create' => false,
'preload' => true,
'options' => // use options
DbTable::find()
->select(['id','name'])
->where(['like', 'name', 'Dim'])
->all(),
],
]);
Is it possible to have a value pre-selected?
When I open a form with this widget on an "update" page I want it to already have the existing data showing, rather than being blank as it would be on the "create" page.
Please could someone advise me on how to achieve this?
I am passing the options to the widget as array $x
'clientOptions' => [ 'valueField' => 'id', 'labelField' => 'name', 'allowEmptyOption' => true, 'preload' => true, 'options'=> $x, ],