2amigos / yii2-selectize-widget

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

Some more Example ? #6

Closed DrMabuse23 closed 10 years ago

DrMabuse23 commented 10 years ago

Hi Sorry how can i use it in an Form ? with model attribute ? with render ?

Thx

tonydspaniard commented 10 years ago

As Autocomplete:

 <?=
        $form->field($model, 'countryName')->widget(Selectize::className(), [
            'url' => Url::to(['country/list']),
            'options' => [
                'placeholder' => 'Enter country',
                'class' => 'form-control',
            ],
            'clientOptions' => [
                'valueField' => 'value',
                'labelField' => 'name',
                'searchField' => 'name',
                'create' => false,
                'preload' => true,
                'maxItems' => 1,
            ],
        ]) ?>

The url renders a JSON with the result of the search:

'[{"name":"yadayada","value":"3"}]'
DrMabuse23 commented 10 years ago

thx