Answer the question
In order to leave comments, you need to log in
How to properly organize the output in the Select2 yii2 card?
Please tell me how to correctly display the results with spaces. Here is the code:
echo Select2::widget([
'id'=>'pacients',
'name' => 'kv_theme_select2',
'initValueText' =>'', // set the initial display text
'theme' => Select2::THEME_CLASSIC, // this is the default if theme is not set
'options' => ['placeholder' => 'Поиск пациента'],
'pluginOptions' => [
'minimumInputLength' => 7,
'allowClear' => true,
'ajax' => [
'url' => $url,
'dataType' => 'json',
'data' => new JsExpression('function(params) { return {q:params.term}; }')
],
'escapeMarkup' => new JsExpression('function (markup) { return markup; }'),
'templateResult' => new JsExpression('function(user) { return user.surname +user.name +user.fathername + user.birthday;}'),
'templateSelection' => new JsExpression('function (pacients) { return pacients.surname+pacients.name+pacients.fathername+pacients.birthday;}'),
],
]);
?>
Answer the question
In order to leave comments, you need to log in
You set the format yourself:
What prevents a space from being inserteduser.surname + ' ' + user.name
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question