Answers.Body: <p>You are using docs for the wrong version of Select2. As you noted, Civi currently uses v3.5. The correct doc link is <a href="https://select2.github.io/select2/" rel="nofollow noreferrer">https://select2.github.io/select2/</a></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-12-08T08:48:29.250Z
Answers.Text: thanks Coleman, we'll check how that helps :-)
Answers.UserDisplayName: Guillaume Sorel
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-12-08T04:17:11.787Z
Answers.LastActivityDate: 2021-12-08T04:17:11.787Z
Answers.UserDisplayName: Coleman
Body: <p>We're working on a french postal codes extension based on the Belgian one.
  We want to use the API provided by the <a href="https://datanova.laposte.fr/explore/dataset/laposte_hexasmal/information/?disjunctive.code_commune_insee&amp;disjunctive.nom_de_la_commune&amp;disjunctive.code_postal&amp;disjunctive.ligne_5" rel="nofollow noreferrer">National French Mail Company</a>.</p>
  <p>According to the <a href="https://select2.org/data-sources/ajax" rel="nofollow noreferrer">Select2</a> doc for Ajax (remote request), we should use the <code>&lt;select&gt;</code> markup but it doesn't work, even though following <a href="https://civicrm.stackexchange.com/questions/19414/multi-select-not-working-with-crmuiselect-angularjs-select2-directive">this post</a>, it should.</p>
  <p>We can see this error in the console <code>Uncaught Error: Option 'ajax' is not allowed for Select2 when attached to a &lt;select&gt; element.</code></p>
  <p>If we use the <code>&lt;input&gt;</code> markup instead, we can get data in the console but it also fails and we have this error: <code>Uncaught TypeError: Cannot read properties of undefined (reading 'toUpperCase')</code> meaning that we need to transform the current result into the proper format using processResults(data) as described in the Select2 documentation.</p>
  <p>We are using CiviCRM 5.43 on WP 5.82 and the standard Select2 library is 3.5.4. Forcing to Select2 version 4 causes a crash.</p>
  <p>Any idea on how to overcome this issue?</p>
  
Tags: <select2>
Title: Issue with select2 widget
ThreadText: # Issue with select2 widget
  
  (Asked by: username_0 on 2021-12-07)
  
  We're working on a french postal codes extension based on the Belgian one.
  We want to use the API provided by the [National French Mail Company](https://datanova.laposte.fr/explore/dataset/laposte_hexasmal/information/?disjunctive.code_commune_insee&disjunctive.nom_de_la_commune&disjunctive.code_postal&disjunctive.ligne_5).
  
  According to the [Select2](https://select2.org/data-sources/ajax) doc for Ajax (remote request), we should use the `<select>` markup but it doesn't work, even though following [this post](https://civicrm.stackexchange.com/questions/19414/multi-select-not-working-with-crmuiselect-angularjs-select2-directive), it should.
  
  We can see this error in the console `Uncaught Error: Option 'ajax' is not allowed for Select2 when attached to a <select> element.`
  
  If we use the `<input>` markup instead, we can get data in the console but it also fails and we have this error: `Uncaught TypeError: Cannot read properties of undefined (reading 'toUpperCase')` meaning that we need to transform the current result into the proper format using processResults(data) as described in the Select2 documentation.
  
  We are using CiviCRM 5.43 on WP 5.82 and the standard Select2 library is 3.5.4. Forcing to Select2 version 4 causes a crash.
  
  Any idea on how to overcome this issue?
  
  **Tags:** select2
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2021-12-08. Score: 1 | Accepted answer
  
  You are using docs for the wrong version of Select2. As you noted, Civi currently uses v3.5. The correct doc link is <https://select2.github.io/select2/>
  
  > **Comments:**
  > **username_0**: thanks username_1, we'll check how that helps :-)  
  
  ---
  
  