Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding new attribute inside ajax load select2 #359

Open
RamiRayya opened this issue Mar 23, 2018 · 0 comments
Open

Adding new attribute inside ajax load select2 #359

RamiRayya opened this issue Mar 23, 2018 · 0 comments

Comments

@RamiRayya
Copy link

RamiRayya commented Mar 23, 2018

                <?= $form->field($detail, "[{$i}]product_id")->widget(Select2::classname(), [
                      'initValueText' =>  $productDesc, // set the initial
                      'options' => ['placeholder' => 'Search for a Salesman ...' , 'id' => 'sem'],
                      'pluginOptions' => [
                          'allowClear' => true,
                          'minimumInputLength' => 3,
                          'language' => [
                              'errorLoading' => new JsExpression("function () { return 'Waiting for results...'; }"),
                          ],
                          'ajax' => [
                              'url' => $productUrl,
                              'dataType' => 'json',
                              'data' => new JsExpression('function(params) { return {q:params.term}; }'),
                          ],
                          'escapeMarkup' => new JsExpression('function (markup) { return markup; }'),
                          'templateResult' => new JsExpression('function(product) { return product.text; }'),
                          'templateSelection' => new JsExpression('function (product) { return product.text; }'),
                      ],
                    ]);
                ?>

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant