Yii Framework Search Dropdown

link

Example

use kartik\widgets\Select2;


<?= $form->field($model, 'AlternativeBrand')->widget(Select2::classname(), [
    'data' => $data,
    'options' => ['placeholder' => 'Select a state ...'],
    'pluginOptions' => [
        'allowClear' => true
    ],
]);?>

-----NOTE----->>>>    'data' => $data, (static variable)

<?= $form->field($model, 'AlternativeBrand')->widget(Select2::classname(), [
'data' => [1 => "First", 2 => "Second", 3 => "Third", 4 => "Fourth", 5 => "Fifth"], 
 'options' => ['placeholder' => 'Select a state ...'],
    'pluginOptions' => [
        'allowClear' => true
    ],
]);?>
------simple------
    <?=  $form->field($model, 'CountryCode')->dropDownList
(['a' => 'Item A', 'b' => 'Item B', 'c' => 'Item C'],['prompt'=>'Select Option']); ?>

Popular posts from this blog

Yii Framework In Update Time View Image In Form

Add a new column to existing table in a migration

Ajax Toggle(on/off) on-click Update