1. <tfoot id='wsns7'></tfoot>
    2. <small id='wsns7'></small><noframes id='wsns7'>

    3. <i id='wsns7'><tr id='wsns7'><dt id='wsns7'><q id='wsns7'><span id='wsns7'><b id='wsns7'><form id='wsns7'><ins id='wsns7'></ins><ul id='wsns7'></ul><sub id='wsns7'></sub></form><legend id='wsns7'></legend><bdo id='wsns7'><pre id='wsns7'><center id='wsns7'></center></pre></bdo></b><th id='wsns7'></th></span></q></dt></tr></i><div id='wsns7'><tfoot id='wsns7'></tfoot><dl id='wsns7'><fieldset id='wsns7'></fieldset></dl></div>
      • <bdo id='wsns7'></bdo><ul id='wsns7'></ul>

      <legend id='wsns7'><style id='wsns7'><dir id='wsns7'><q id='wsns7'></q></dir></style></legend>

      Yii2:Jui Auto Complete Widget 怎么做?

      时间:2023-10-16

      <small id='Z4HzU'></small><noframes id='Z4HzU'>

        <bdo id='Z4HzU'></bdo><ul id='Z4HzU'></ul>

      • <legend id='Z4HzU'><style id='Z4HzU'><dir id='Z4HzU'><q id='Z4HzU'></q></dir></style></legend>

        <i id='Z4HzU'><tr id='Z4HzU'><dt id='Z4HzU'><q id='Z4HzU'><span id='Z4HzU'><b id='Z4HzU'><form id='Z4HzU'><ins id='Z4HzU'></ins><ul id='Z4HzU'></ul><sub id='Z4HzU'></sub></form><legend id='Z4HzU'></legend><bdo id='Z4HzU'><pre id='Z4HzU'><center id='Z4HzU'></center></pre></bdo></b><th id='Z4HzU'></th></span></q></dt></tr></i><div id='Z4HzU'><tfoot id='Z4HzU'></tfoot><dl id='Z4HzU'><fieldset id='Z4HzU'></fieldset></dl></div>
        <tfoot id='Z4HzU'></tfoot>
            <tbody id='Z4HzU'></tbody>

              • 本文介绍了Yii2:Jui Auto Complete Widget 怎么做?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我正在尝试使用 yii2 Jui 自动完成小部件.

                I am trying to use yii2 Jui autocomplete widget.

                我有这段代码可以正确显示自动完成日期,但我无法保存数据.

                I have this code which is showing the auto-complete date correctly, but I am not able to save the data.

                $data=ArrayHelper::map(State::find()->all(), 'id', 'state_name' );
                $data=array_merge($data);
                

                然后

                echo 'State' .'<br>';
                  echo AutoComplete::widget([
                    'model'=>$model,
                    'attribute' => 'state_id',     
                    'clientOptions' => [
                        'source' => $data,        
                    ],
                ]);
                

                任何解决方案将不胜感激.谢谢.

                Any solution will be greatly appreciated. Thanks.

                推荐答案

                好的,我找到了解决方案,它是这样的:

                Ok I found the solution, it goes like this:

                use yiijuiAutoComplete;
                use yiiwebJsExpression;
                

                那么:

                $data = State::find()
                    ->select(['state_name as value', 'state_name as  label','id as id'])
                    ->asArray()
                    ->all();
                

                然后

                echo 'State' .'<br>';
                  echo AutoComplete::widget([
                    'name' => 'State',    
                    'id' => 'ddd',
                    'clientOptions' => [
                        'source' => $data, 
                        'autoFill'=>true,
                         'select' => new JsExpression("function( event, ui ) {
                        $('#city-state_name').val(ui.item.id);//#City-state_name is the id of hiddenInput.
                     }")],
                     ]);
                

                最后:

                <?= Html::activeHiddenInput($model, 'state_name')?>
                

                仅此而已.希望有人会发现它有用.谢谢.

                That is all. Hope some one will find it useful. Thanks.

                这篇关于Yii2:Jui Auto Complete Widget 怎么做?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:保存、组织和查询产品、选项/标签和类别 下一篇:yii2 中的自动完成

                相关文章

                    <bdo id='WXcPF'></bdo><ul id='WXcPF'></ul>
                  <i id='WXcPF'><tr id='WXcPF'><dt id='WXcPF'><q id='WXcPF'><span id='WXcPF'><b id='WXcPF'><form id='WXcPF'><ins id='WXcPF'></ins><ul id='WXcPF'></ul><sub id='WXcPF'></sub></form><legend id='WXcPF'></legend><bdo id='WXcPF'><pre id='WXcPF'><center id='WXcPF'></center></pre></bdo></b><th id='WXcPF'></th></span></q></dt></tr></i><div id='WXcPF'><tfoot id='WXcPF'></tfoot><dl id='WXcPF'><fieldset id='WXcPF'></fieldset></dl></div>

                  <small id='WXcPF'></small><noframes id='WXcPF'>

                1. <legend id='WXcPF'><style id='WXcPF'><dir id='WXcPF'><q id='WXcPF'></q></dir></style></legend>
                2. <tfoot id='WXcPF'></tfoot>