1

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.

According to the Select2 doc for Ajax (remote request), we should use the <select> markup but it doesn't work, even though following this post, 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?

1 Answer 1

1

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/

1
  • thanks Coleman, we'll check how that helps :-) Commented Dec 8, 2021 at 8:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.