Answers.Body: <p>You could use <a href="https://select2.org/getting-started/basic-usage" rel="nofollow noreferrer">Select2</a> to search in a select field </p>
  
  <pre><code>$(document).ready(function() {
      $('.my-custom-awesome-select-class').select2();
  });
  </code></pre>
  
  <p>All you need to do is to include the js file via asset bundle or register it in your view directly and execute the JS code </p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-06-29T14:05:02.273Z
Answers.LastActivityDate: 2018-06-29T14:05:02.273Z
Answers.UserDisplayName: Robin Schambach
Body: <p>I created a custom FieldType that gathers data from 2 different Models. I was able to successfully display it as a Drop Down. My problem now is that there are tooo many records on my array and I would like to have a search instead similar to what craft already has implemented on the Tags Field.</p>
  
  <p>My current template is:</p>
  
  <pre><code>    {%- set class = [
      'select',
      (class is defined ? class : null)
      ]|filter|join(' ') %}
  
      {% set selectedValue = (value is defined ? value : null)  %}
  
      &lt;div class="{{ class }}"&gt;
          &lt;select {%- if name is defined %} name="{{ name }}"{% endif %}&gt;
      {% if value is not null %}
      {% set selectedValue = value.id %}
      {% endif %}
      {% else %}
      &lt;option value="0" &gt; &lt;/option&gt;
      {% endif %}
  
      {% for test in tests %}
      {% set optionValue = test.id %}
      &lt;option value="{{test.id}}" {% if optionValue == selectedValue %} selected{% endif %}&gt;Test - {{ test.name }}: {{ test.price }}&lt;/option&gt;
              {% endfor %}
          &lt;/select&gt;
      &lt;/div&gt;
  </code></pre>
  
  <p>Any way I can make it similar to the <code>craft/app/templates/_components/fieldtypes/Tags/input.html</code></p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-06-29T13:58:15.473Z
Comments.Text: Would it be an option to use an external library like https://select2.org/dropdown ? Otherwise you'll need to create a custom script for it
Comments.UserDisplayName: Robin Schambach
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-06-29T13:59:51.727Z
Comments.Text: That would be amazing. not sure how to implement. any advice?
Comments.UserDisplayName: juanmrad
Tags: <templating><custom-fieldtype>
Title: Input Tags Template for my Custom FieldType
ThreadText: # Input Tags Template for my Custom FieldType
  
  (Asked by: username_0 on 2018-06-29)
  
  I created a custom FieldType that gathers data from 2 different Models. I was able to successfully display it as a Drop Down. My problem now is that there are tooo many records on my array and I would like to have a search instead similar to what craft already has implemented on the Tags Field.
  
  My current template is:
  
  ```
      {%- set class = [
      'select',
      (class is defined ? class : null)
      ]|filter|join(' ') %}
  
      {% set selectedValue = (value is defined ? value : null)  %}
  
      <div class="{{ class }}">
          <select {%- if name is defined %} name="{{ name }}"{% endif %}>
      {% if value is not null %}
      {% set selectedValue = value.id %}
      {% endif %}
      {% else %}
      <option value="0" > </option>
      {% endif %}
  
      {% for test in tests %}
      {% set optionValue = test.id %}
      <option value="{{test.id}}" {% if optionValue == selectedValue %} selected{% endif %}>Test - {{ test.name }}: {{ test.price }}</option>
              {% endfor %}
          </select>
      </div>
  
  ```
  
  Any way I can make it similar to the `craft/app/templates/_components/fieldtypes/Tags/input.html`
  
  **Tags:** templating, custom-fieldtype
  
  > **Comments:**
  > **username_1**: Would it be an option to use an external library like https://select2.org/dropdown ? Otherwise you'll need to create a custom script for it  
  > **username_0**: That would be amazing. not sure how to implement. any advice?  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2018-06-29. Score: 2 | Accepted answer
  
  You could use [Select2](https://select2.org/getting-started/basic-usage) to search in a select field
  
  ```
  $(document).ready(function() {
      $('.my-custom-awesome-select-class').select2();
  });
  
  ```
  
  All you need to do is to include the js file via asset bundle or register it in your view directly and execute the JS code
  
  
  ---
  
  