How to combine two attributes on select2 in yii2









up vote
-1
down vote

favorite
1












I want to combine two attributes on select2 like this:



1



I want to attribute kodepos and kabupaten in one dropdown. and kodepos and kabupaten attributes are included in the database. Can anyone help me? thank you



<?= $form->field($model, 'origin')->label('Origin')->widget(Select2::classname(), [
'data' => ArrayHelper::map(MKota::find()->all(),'kodepos','kodepos'),
'theme' => Select2::THEME_BOOTSTRAP,
'language' => 'en',
'options' => ['placeholder' => 'Pilih Kode Pos','required' => true,'style'=>'width:500px','maxlength' => true],
'pluginOptions' => [
'allowClear' => true
],
]);
?>

<?= $form->field($model, 'origin_name')->label('Origin')->widget(Select2::classname(), [
'data' => ArrayHelper::map(MKota::find()->all(),'kabupaten','kabupaten'),
'theme' => Select2::THEME_BOOTSTRAP,
'language' => 'en',
'options' => ['placeholder' => 'Pilih Kota Asal','required' => true,'style'=>'width:500px','maxlength' => true],
'pluginOptions' => [
'allowClear' => true
],
]);
?>









share|improve this question























  • not clear what are the names of the attributes that you want to show there? there are 2 different select dropdowns that you are talking about, you need to add which attributes you want to show as text for the first and second drop-down.
    – Muhammad Omer Aslam
    Nov 11 at 16:14










  • sorry, I want to attribute kodepos and kabupaten in one dropdown
    – Herdi
    Nov 11 at 16:39










  • you want a single dropdown instead of 2 drop-downs ? if i am getting you correctly
    – Muhammad Omer Aslam
    Nov 11 at 16:42










  • i have added an answer below with an update see EDIT part for correct solution.
    – Muhammad Omer Aslam
    Nov 11 at 16:43















up vote
-1
down vote

favorite
1












I want to combine two attributes on select2 like this:



1



I want to attribute kodepos and kabupaten in one dropdown. and kodepos and kabupaten attributes are included in the database. Can anyone help me? thank you



<?= $form->field($model, 'origin')->label('Origin')->widget(Select2::classname(), [
'data' => ArrayHelper::map(MKota::find()->all(),'kodepos','kodepos'),
'theme' => Select2::THEME_BOOTSTRAP,
'language' => 'en',
'options' => ['placeholder' => 'Pilih Kode Pos','required' => true,'style'=>'width:500px','maxlength' => true],
'pluginOptions' => [
'allowClear' => true
],
]);
?>

<?= $form->field($model, 'origin_name')->label('Origin')->widget(Select2::classname(), [
'data' => ArrayHelper::map(MKota::find()->all(),'kabupaten','kabupaten'),
'theme' => Select2::THEME_BOOTSTRAP,
'language' => 'en',
'options' => ['placeholder' => 'Pilih Kota Asal','required' => true,'style'=>'width:500px','maxlength' => true],
'pluginOptions' => [
'allowClear' => true
],
]);
?>









share|improve this question























  • not clear what are the names of the attributes that you want to show there? there are 2 different select dropdowns that you are talking about, you need to add which attributes you want to show as text for the first and second drop-down.
    – Muhammad Omer Aslam
    Nov 11 at 16:14










  • sorry, I want to attribute kodepos and kabupaten in one dropdown
    – Herdi
    Nov 11 at 16:39










  • you want a single dropdown instead of 2 drop-downs ? if i am getting you correctly
    – Muhammad Omer Aslam
    Nov 11 at 16:42










  • i have added an answer below with an update see EDIT part for correct solution.
    – Muhammad Omer Aslam
    Nov 11 at 16:43













up vote
-1
down vote

favorite
1









up vote
-1
down vote

favorite
1






1





I want to combine two attributes on select2 like this:



1



I want to attribute kodepos and kabupaten in one dropdown. and kodepos and kabupaten attributes are included in the database. Can anyone help me? thank you



<?= $form->field($model, 'origin')->label('Origin')->widget(Select2::classname(), [
'data' => ArrayHelper::map(MKota::find()->all(),'kodepos','kodepos'),
'theme' => Select2::THEME_BOOTSTRAP,
'language' => 'en',
'options' => ['placeholder' => 'Pilih Kode Pos','required' => true,'style'=>'width:500px','maxlength' => true],
'pluginOptions' => [
'allowClear' => true
],
]);
?>

<?= $form->field($model, 'origin_name')->label('Origin')->widget(Select2::classname(), [
'data' => ArrayHelper::map(MKota::find()->all(),'kabupaten','kabupaten'),
'theme' => Select2::THEME_BOOTSTRAP,
'language' => 'en',
'options' => ['placeholder' => 'Pilih Kota Asal','required' => true,'style'=>'width:500px','maxlength' => true],
'pluginOptions' => [
'allowClear' => true
],
]);
?>









share|improve this question















I want to combine two attributes on select2 like this:



1



I want to attribute kodepos and kabupaten in one dropdown. and kodepos and kabupaten attributes are included in the database. Can anyone help me? thank you



<?= $form->field($model, 'origin')->label('Origin')->widget(Select2::classname(), [
'data' => ArrayHelper::map(MKota::find()->all(),'kodepos','kodepos'),
'theme' => Select2::THEME_BOOTSTRAP,
'language' => 'en',
'options' => ['placeholder' => 'Pilih Kode Pos','required' => true,'style'=>'width:500px','maxlength' => true],
'pluginOptions' => [
'allowClear' => true
],
]);
?>

<?= $form->field($model, 'origin_name')->label('Origin')->widget(Select2::classname(), [
'data' => ArrayHelper::map(MKota::find()->all(),'kabupaten','kabupaten'),
'theme' => Select2::THEME_BOOTSTRAP,
'language' => 'en',
'options' => ['placeholder' => 'Pilih Kota Asal','required' => true,'style'=>'width:500px','maxlength' => true],
'pluginOptions' => [
'allowClear' => true
],
]);
?>






yii yii2 yii2-advanced-app






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 11 at 17:53

























asked Nov 11 at 12:29









Herdi

75




75











  • not clear what are the names of the attributes that you want to show there? there are 2 different select dropdowns that you are talking about, you need to add which attributes you want to show as text for the first and second drop-down.
    – Muhammad Omer Aslam
    Nov 11 at 16:14










  • sorry, I want to attribute kodepos and kabupaten in one dropdown
    – Herdi
    Nov 11 at 16:39










  • you want a single dropdown instead of 2 drop-downs ? if i am getting you correctly
    – Muhammad Omer Aslam
    Nov 11 at 16:42










  • i have added an answer below with an update see EDIT part for correct solution.
    – Muhammad Omer Aslam
    Nov 11 at 16:43

















  • not clear what are the names of the attributes that you want to show there? there are 2 different select dropdowns that you are talking about, you need to add which attributes you want to show as text for the first and second drop-down.
    – Muhammad Omer Aslam
    Nov 11 at 16:14










  • sorry, I want to attribute kodepos and kabupaten in one dropdown
    – Herdi
    Nov 11 at 16:39










  • you want a single dropdown instead of 2 drop-downs ? if i am getting you correctly
    – Muhammad Omer Aslam
    Nov 11 at 16:42










  • i have added an answer below with an update see EDIT part for correct solution.
    – Muhammad Omer Aslam
    Nov 11 at 16:43
















not clear what are the names of the attributes that you want to show there? there are 2 different select dropdowns that you are talking about, you need to add which attributes you want to show as text for the first and second drop-down.
– Muhammad Omer Aslam
Nov 11 at 16:14




not clear what are the names of the attributes that you want to show there? there are 2 different select dropdowns that you are talking about, you need to add which attributes you want to show as text for the first and second drop-down.
– Muhammad Omer Aslam
Nov 11 at 16:14












sorry, I want to attribute kodepos and kabupaten in one dropdown
– Herdi
Nov 11 at 16:39




sorry, I want to attribute kodepos and kabupaten in one dropdown
– Herdi
Nov 11 at 16:39












you want a single dropdown instead of 2 drop-downs ? if i am getting you correctly
– Muhammad Omer Aslam
Nov 11 at 16:42




you want a single dropdown instead of 2 drop-downs ? if i am getting you correctly
– Muhammad Omer Aslam
Nov 11 at 16:42












i have added an answer below with an update see EDIT part for correct solution.
– Muhammad Omer Aslam
Nov 11 at 16:43





i have added an answer below with an update see EDIT part for correct solution.
– Muhammad Omer Aslam
Nov 11 at 16:43













1 Answer
1






active

oldest

votes

















up vote
0
down vote



accepted










You need to change the ArrayHelper::map() to use the closure for the third parameter or the $to parameter and return the 2 fields concatenated as you want.



The field names are not clear that you want to show as text in the first and second drop-down so I assume the integer value to be coming from the id field.



I will add the code that will show the id and kodepos concatenated as the text for the first drop-down and show the id and kabupaten concatenated as the text for the second drop-down. Change them accordingly in the code



<?= $form->field($model, 'origin')->label('Origin')->widget(Select2::classname(), [
'data' => ArrayHelper::map(MKota::find()->all(),'kodepos',function($model)return $model->id.$model->kodepos),
'theme' => Select2::THEME_BOOTSTRAP,
'language' => 'en',
'options' => ['placeholder' => 'Pilih Kode Pos','required' => true,'style'=>'width:500px','maxlength' => true],
'pluginOptions' => [
'allowClear' => true
],
]);
?>

<?= $form->field($model, 'origin_name')->label('Origin')->widget(Select2::classname(), [
'data' => ArrayHelper::map(MKota::find()->all(),'kabupaten',function($model)return $model->id.$model->kabupaten),
'theme' => Select2::THEME_BOOTSTRAP,
'language' => 'en',
'options' => ['placeholder' => 'Pilih Kota Asal','required' => true,'style'=>'width:500px','maxlength' => true],
'pluginOptions' => [
'allowClear' => true
],
]);
?>


EDIT:



You want the kodepos and kabupaten in one drop-down rather than making 2 drop-downs so change the code to the following



<?= $form->field($model, 'origin')->label('Origin')->widget(Select2::classname(), [
'data' => ArrayHelper::map(MKota::find()->all(),function($model)return $model->kodepos.$model->kabupaten),function($model)return $model->kodepos.$model->kabupaten),
'theme' => Select2::THEME_BOOTSTRAP,
'language' => 'en',
'options' => ['placeholder' => 'Pilih Kode Pos','required' => true,'style'=>'width:500px','maxlength' => true],
'pluginOptions' => [
'allowClear' => true
],
]);
?>





share|improve this answer






















  • the dropdown is correct. thank you. but only kodepos attributes are included in the database. i want the kabupaten attribute to enter also in the database
    – Herdi
    Nov 11 at 17:46










  • are you saying that you want to save the kodepos and kabupaten for the field name origin in the database? @Herdi
    – Muhammad Omer Aslam
    Nov 11 at 17:51










  • yes sir, is it possible?
    – Herdi
    Nov 11 at 17:56










  • well, change the $from parameter to use closure in the same way as i did for the $to and return your desired fields from the closure. @Herdi
    – Muhammad Omer Aslam
    Nov 11 at 17:58










  • Sorry, I don't understand
    – Herdi
    Nov 11 at 18:09










Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53248772%2fhow-to-combine-two-attributes-on-select2-in-yii2%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
0
down vote



accepted










You need to change the ArrayHelper::map() to use the closure for the third parameter or the $to parameter and return the 2 fields concatenated as you want.



The field names are not clear that you want to show as text in the first and second drop-down so I assume the integer value to be coming from the id field.



I will add the code that will show the id and kodepos concatenated as the text for the first drop-down and show the id and kabupaten concatenated as the text for the second drop-down. Change them accordingly in the code



<?= $form->field($model, 'origin')->label('Origin')->widget(Select2::classname(), [
'data' => ArrayHelper::map(MKota::find()->all(),'kodepos',function($model)return $model->id.$model->kodepos),
'theme' => Select2::THEME_BOOTSTRAP,
'language' => 'en',
'options' => ['placeholder' => 'Pilih Kode Pos','required' => true,'style'=>'width:500px','maxlength' => true],
'pluginOptions' => [
'allowClear' => true
],
]);
?>

<?= $form->field($model, 'origin_name')->label('Origin')->widget(Select2::classname(), [
'data' => ArrayHelper::map(MKota::find()->all(),'kabupaten',function($model)return $model->id.$model->kabupaten),
'theme' => Select2::THEME_BOOTSTRAP,
'language' => 'en',
'options' => ['placeholder' => 'Pilih Kota Asal','required' => true,'style'=>'width:500px','maxlength' => true],
'pluginOptions' => [
'allowClear' => true
],
]);
?>


EDIT:



You want the kodepos and kabupaten in one drop-down rather than making 2 drop-downs so change the code to the following



<?= $form->field($model, 'origin')->label('Origin')->widget(Select2::classname(), [
'data' => ArrayHelper::map(MKota::find()->all(),function($model)return $model->kodepos.$model->kabupaten),function($model)return $model->kodepos.$model->kabupaten),
'theme' => Select2::THEME_BOOTSTRAP,
'language' => 'en',
'options' => ['placeholder' => 'Pilih Kode Pos','required' => true,'style'=>'width:500px','maxlength' => true],
'pluginOptions' => [
'allowClear' => true
],
]);
?>





share|improve this answer






















  • the dropdown is correct. thank you. but only kodepos attributes are included in the database. i want the kabupaten attribute to enter also in the database
    – Herdi
    Nov 11 at 17:46










  • are you saying that you want to save the kodepos and kabupaten for the field name origin in the database? @Herdi
    – Muhammad Omer Aslam
    Nov 11 at 17:51










  • yes sir, is it possible?
    – Herdi
    Nov 11 at 17:56










  • well, change the $from parameter to use closure in the same way as i did for the $to and return your desired fields from the closure. @Herdi
    – Muhammad Omer Aslam
    Nov 11 at 17:58










  • Sorry, I don't understand
    – Herdi
    Nov 11 at 18:09














up vote
0
down vote



accepted










You need to change the ArrayHelper::map() to use the closure for the third parameter or the $to parameter and return the 2 fields concatenated as you want.



The field names are not clear that you want to show as text in the first and second drop-down so I assume the integer value to be coming from the id field.



I will add the code that will show the id and kodepos concatenated as the text for the first drop-down and show the id and kabupaten concatenated as the text for the second drop-down. Change them accordingly in the code



<?= $form->field($model, 'origin')->label('Origin')->widget(Select2::classname(), [
'data' => ArrayHelper::map(MKota::find()->all(),'kodepos',function($model)return $model->id.$model->kodepos),
'theme' => Select2::THEME_BOOTSTRAP,
'language' => 'en',
'options' => ['placeholder' => 'Pilih Kode Pos','required' => true,'style'=>'width:500px','maxlength' => true],
'pluginOptions' => [
'allowClear' => true
],
]);
?>

<?= $form->field($model, 'origin_name')->label('Origin')->widget(Select2::classname(), [
'data' => ArrayHelper::map(MKota::find()->all(),'kabupaten',function($model)return $model->id.$model->kabupaten),
'theme' => Select2::THEME_BOOTSTRAP,
'language' => 'en',
'options' => ['placeholder' => 'Pilih Kota Asal','required' => true,'style'=>'width:500px','maxlength' => true],
'pluginOptions' => [
'allowClear' => true
],
]);
?>


EDIT:



You want the kodepos and kabupaten in one drop-down rather than making 2 drop-downs so change the code to the following



<?= $form->field($model, 'origin')->label('Origin')->widget(Select2::classname(), [
'data' => ArrayHelper::map(MKota::find()->all(),function($model)return $model->kodepos.$model->kabupaten),function($model)return $model->kodepos.$model->kabupaten),
'theme' => Select2::THEME_BOOTSTRAP,
'language' => 'en',
'options' => ['placeholder' => 'Pilih Kode Pos','required' => true,'style'=>'width:500px','maxlength' => true],
'pluginOptions' => [
'allowClear' => true
],
]);
?>





share|improve this answer






















  • the dropdown is correct. thank you. but only kodepos attributes are included in the database. i want the kabupaten attribute to enter also in the database
    – Herdi
    Nov 11 at 17:46










  • are you saying that you want to save the kodepos and kabupaten for the field name origin in the database? @Herdi
    – Muhammad Omer Aslam
    Nov 11 at 17:51










  • yes sir, is it possible?
    – Herdi
    Nov 11 at 17:56










  • well, change the $from parameter to use closure in the same way as i did for the $to and return your desired fields from the closure. @Herdi
    – Muhammad Omer Aslam
    Nov 11 at 17:58










  • Sorry, I don't understand
    – Herdi
    Nov 11 at 18:09












up vote
0
down vote



accepted







up vote
0
down vote



accepted






You need to change the ArrayHelper::map() to use the closure for the third parameter or the $to parameter and return the 2 fields concatenated as you want.



The field names are not clear that you want to show as text in the first and second drop-down so I assume the integer value to be coming from the id field.



I will add the code that will show the id and kodepos concatenated as the text for the first drop-down and show the id and kabupaten concatenated as the text for the second drop-down. Change them accordingly in the code



<?= $form->field($model, 'origin')->label('Origin')->widget(Select2::classname(), [
'data' => ArrayHelper::map(MKota::find()->all(),'kodepos',function($model)return $model->id.$model->kodepos),
'theme' => Select2::THEME_BOOTSTRAP,
'language' => 'en',
'options' => ['placeholder' => 'Pilih Kode Pos','required' => true,'style'=>'width:500px','maxlength' => true],
'pluginOptions' => [
'allowClear' => true
],
]);
?>

<?= $form->field($model, 'origin_name')->label('Origin')->widget(Select2::classname(), [
'data' => ArrayHelper::map(MKota::find()->all(),'kabupaten',function($model)return $model->id.$model->kabupaten),
'theme' => Select2::THEME_BOOTSTRAP,
'language' => 'en',
'options' => ['placeholder' => 'Pilih Kota Asal','required' => true,'style'=>'width:500px','maxlength' => true],
'pluginOptions' => [
'allowClear' => true
],
]);
?>


EDIT:



You want the kodepos and kabupaten in one drop-down rather than making 2 drop-downs so change the code to the following



<?= $form->field($model, 'origin')->label('Origin')->widget(Select2::classname(), [
'data' => ArrayHelper::map(MKota::find()->all(),function($model)return $model->kodepos.$model->kabupaten),function($model)return $model->kodepos.$model->kabupaten),
'theme' => Select2::THEME_BOOTSTRAP,
'language' => 'en',
'options' => ['placeholder' => 'Pilih Kode Pos','required' => true,'style'=>'width:500px','maxlength' => true],
'pluginOptions' => [
'allowClear' => true
],
]);
?>





share|improve this answer














You need to change the ArrayHelper::map() to use the closure for the third parameter or the $to parameter and return the 2 fields concatenated as you want.



The field names are not clear that you want to show as text in the first and second drop-down so I assume the integer value to be coming from the id field.



I will add the code that will show the id and kodepos concatenated as the text for the first drop-down and show the id and kabupaten concatenated as the text for the second drop-down. Change them accordingly in the code



<?= $form->field($model, 'origin')->label('Origin')->widget(Select2::classname(), [
'data' => ArrayHelper::map(MKota::find()->all(),'kodepos',function($model)return $model->id.$model->kodepos),
'theme' => Select2::THEME_BOOTSTRAP,
'language' => 'en',
'options' => ['placeholder' => 'Pilih Kode Pos','required' => true,'style'=>'width:500px','maxlength' => true],
'pluginOptions' => [
'allowClear' => true
],
]);
?>

<?= $form->field($model, 'origin_name')->label('Origin')->widget(Select2::classname(), [
'data' => ArrayHelper::map(MKota::find()->all(),'kabupaten',function($model)return $model->id.$model->kabupaten),
'theme' => Select2::THEME_BOOTSTRAP,
'language' => 'en',
'options' => ['placeholder' => 'Pilih Kota Asal','required' => true,'style'=>'width:500px','maxlength' => true],
'pluginOptions' => [
'allowClear' => true
],
]);
?>


EDIT:



You want the kodepos and kabupaten in one drop-down rather than making 2 drop-downs so change the code to the following



<?= $form->field($model, 'origin')->label('Origin')->widget(Select2::classname(), [
'data' => ArrayHelper::map(MKota::find()->all(),function($model)return $model->kodepos.$model->kabupaten),function($model)return $model->kodepos.$model->kabupaten),
'theme' => Select2::THEME_BOOTSTRAP,
'language' => 'en',
'options' => ['placeholder' => 'Pilih Kode Pos','required' => true,'style'=>'width:500px','maxlength' => true],
'pluginOptions' => [
'allowClear' => true
],
]);
?>






share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 11 at 18:20

























answered Nov 11 at 16:21









Muhammad Omer Aslam

11.8k62344




11.8k62344











  • the dropdown is correct. thank you. but only kodepos attributes are included in the database. i want the kabupaten attribute to enter also in the database
    – Herdi
    Nov 11 at 17:46










  • are you saying that you want to save the kodepos and kabupaten for the field name origin in the database? @Herdi
    – Muhammad Omer Aslam
    Nov 11 at 17:51










  • yes sir, is it possible?
    – Herdi
    Nov 11 at 17:56










  • well, change the $from parameter to use closure in the same way as i did for the $to and return your desired fields from the closure. @Herdi
    – Muhammad Omer Aslam
    Nov 11 at 17:58










  • Sorry, I don't understand
    – Herdi
    Nov 11 at 18:09
















  • the dropdown is correct. thank you. but only kodepos attributes are included in the database. i want the kabupaten attribute to enter also in the database
    – Herdi
    Nov 11 at 17:46










  • are you saying that you want to save the kodepos and kabupaten for the field name origin in the database? @Herdi
    – Muhammad Omer Aslam
    Nov 11 at 17:51










  • yes sir, is it possible?
    – Herdi
    Nov 11 at 17:56










  • well, change the $from parameter to use closure in the same way as i did for the $to and return your desired fields from the closure. @Herdi
    – Muhammad Omer Aslam
    Nov 11 at 17:58










  • Sorry, I don't understand
    – Herdi
    Nov 11 at 18:09















the dropdown is correct. thank you. but only kodepos attributes are included in the database. i want the kabupaten attribute to enter also in the database
– Herdi
Nov 11 at 17:46




the dropdown is correct. thank you. but only kodepos attributes are included in the database. i want the kabupaten attribute to enter also in the database
– Herdi
Nov 11 at 17:46












are you saying that you want to save the kodepos and kabupaten for the field name origin in the database? @Herdi
– Muhammad Omer Aslam
Nov 11 at 17:51




are you saying that you want to save the kodepos and kabupaten for the field name origin in the database? @Herdi
– Muhammad Omer Aslam
Nov 11 at 17:51












yes sir, is it possible?
– Herdi
Nov 11 at 17:56




yes sir, is it possible?
– Herdi
Nov 11 at 17:56












well, change the $from parameter to use closure in the same way as i did for the $to and return your desired fields from the closure. @Herdi
– Muhammad Omer Aslam
Nov 11 at 17:58




well, change the $from parameter to use closure in the same way as i did for the $to and return your desired fields from the closure. @Herdi
– Muhammad Omer Aslam
Nov 11 at 17:58












Sorry, I don't understand
– Herdi
Nov 11 at 18:09




Sorry, I don't understand
– Herdi
Nov 11 at 18:09

















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53248772%2fhow-to-combine-two-attributes-on-select2-in-yii2%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Top Tejano songwriter Luis Silva dead of heart attack at 64

政党

天津地下鉄3号線