echo Select2::widget([
'model' => $vendorModel,
'attribute' => 'id',
'data' => $vendor,
'options' => ['placeholder' => 'Select a vendor ...'],
'pluginOptions' => [
'allowClear' => true
],
]);
The above Select2 widget (and most of widgets are same) require the Model attribute, but I don't know what the model does in Widget, because even if I put the any other model object, it works.
replaced model with $userModel that doesn't relate with vendor model at all and I tried, and it works.
echo Select2::widget([
'model' => $userModel,
'attribute' => 'id',
'data' => $vendor,
'options' => ['placeholder' => 'Select a vendor ...'],
'pluginOptions' => [
'allowClear' => true
],
]);
How should I understand the Model?