title: result by AJAX not selectable
body: <p>The following code will give me all records using AJAX request as intended. Unfortunately, I am not able to take one selected record into form. I just can select them, not take them(Look at my attachment, please). I assume some error in <code>templateResult</code> or <code>templateSelection</code>.</p>
  
  <p><strong>Rephrasing question</strong>:
  'can't select' means, that I am not able to adopt one single record- beeing displayed- into formular. It's like food for a dog which can't be eaten by the dog,'cause hand will be moved away again and again...
  Hope this helped understanding my question.
  P.S.:id_ba_xml_gelernter_beruf_1 is Propertie of model</p>
  
  <p>Here is code of formular:</p>
  
  <pre><code>$url = \yii\helpers\Url::to ( [ 'berufe' ] );
      ?&gt;&lt;?=
      $form-&gt;field ( $model , 'id_ba_xml_gelernter_beruf_1' , [ 'addon' =&gt; [
              'prepend' =&gt; [ 'content' =&gt; 'gelernter Beruf 1' ] ] ] )-&gt;widget ( \kartik\widgets\Select2::classname () , [
          'options' =&gt; [ 'placeholder' =&gt; 'Berufe suchen ...' ] ,
          'pluginOptions' =&gt; [
              'allowClear' =&gt; true ,
              'minimumInputLength' =&gt; 3 ,
              'language' =&gt; [
                  'errorLoading' =&gt; new JsExpression ( "function () { return 'Waiting for results...'; }" ) ,
              ] ,
              'ajax' =&gt; [
                  'url' =&gt; $url ,
                  'dataType' =&gt; 'json' ,
                  'data' =&gt; new JsExpression ( 'function(params) { return {q:params.term}; }' )
              ] ,
              'escapeMarkup' =&gt; new JsExpression ( 'function (markup) { return markup; }' ) ,
              'templateResult' =&gt; new JsExpression ( 'function(id_ba_xml_gelernter_beruf_1) { return id_ba_xml_gelernter_beruf_1.text; }' ) ,
              'templateSelection' =&gt; new JsExpression ( 'function (id_ba_xml_gelernter_beruf_1) { return id_ba_xml_gelernter_beruf_1.text; }' ) ,
          ] ,
      ] )-&gt;label ( false );
  </code></pre>
  
  <p>Here is ControllerCode which works pretty fine</p>
  
  <pre><code>public function actionBerufe( $q = null , $id = null ) {
      \Yii::$app-&gt;response-&gt;format = \yii\web\Response::FORMAT_JSON;
      $out = [ 'results' =&gt; [ 'id' =&gt; '' , 'text' =&gt; '' ] ];
      if ( !is_null ( $q ) ) {
          $query = new \yii\db\Query();
          $query-&gt;select ( 'ID, Bezeichnung_neutral_kurz  AS text' )
                  -&gt;from ( 'yii2_ba.ba_berufe' )
                  -&gt;where ( [ 'like' , 'Bezeichnung_neutral_kurz' , $q ] )
                  -&gt;limit ( 20 );
          $command = $query-&gt;createCommand ();
          $data = $command-&gt;queryAll ();
          $out['results'] = array_values ( $data );
      } elseif ( $id &gt; 0 ) {
          $out['results'] = [ 'id' =&gt; $id , 'text' =&gt; \common\modules\basis\models\BaBerufe::find ( $id )-&gt;Bezeichnung_neutral_kurz ];
      }
      return $out;
  }
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/7YsCk.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7YsCk.jpg" alt="enter image description here"></a></p>