I
I
Iossarian2019-06-26 17:05:15
Yii
Iossarian, 2019-06-26 17:05:15

How to display value from DaData in Select2?

Good afternoon. There is select2 and there is DaData . The information is immediately filled in the text input fields, but there is a problem with the select: the value gets there correctly, but is not pulled up for display to the user, which is why he tries to set it with his hands, thinking that it was not set. Tell me how you can pull up the value for display to the user? Thank you.
Widget code:

<?= $form->field($model, 'type')->widget(Select2::classname(), [
                        'data' => [
                            'INDIVIDUAL' => 'ИП',
                            'LEGAL' => 'ООО'
                        ],
                        'pluginOptions' => [
                            'placeholder' => 'Выберите тип организации',
                            'hideSearch' => true,
                        ],
                    ]
                ) ?>

So the value gets there:
onSelect: function (suggestion) {
            console.log(suggestion.data);
            $('#paymentinfo-type').val(suggestion.data.type);

5d137b6a74af7246106287.png

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question