Problem/Motivation

Selectize currently only supports forms created programmatically using the Form API; any fields created with the Field API are not supported. Providing support for Field API fields would greatly improve the usefulness of the module.

Proposed resolution

  • Alter field widget info to add selectize settings
  • Alter field_ui edit forms to allow site builders to set selectize settings
  • Alter field widget forms to add js settings for selectize widgets
  • Add javascript to deal with Field API implementations of autocomplete callbacks, etc.

Remaining tasks

  • Review needed
  • Testing of all selectize options

User interface changes

  • Adds settings for Selectize to Field UI forms.
  • Can replace select elements with selectize.js element
  • Can replace beloved but outdated Drupal autocomplete elements (e.g. taxonomy, entityreference) with selectize.js elements

API changes

None

Data model changes

None

Comments

dnotes created an issue. See original summary.

dnotes’s picture

Title: Support Field API for taxonomy, entityreference, select fields, etc. » Support Field API for taxonomy, entityreference, select fields
Related issues: +#2678916: Add support for entity reference with autocomplete
StatusFileSize
new10.78 KB

Patch is attached. I'll mark the Entity Reference issue as related, since this patch solves that problem. Would love to work on a Drupal 8 version if I get time; personally, I think selectize.js is absolutely fantastic and should replace Drupal's autocomplete functionality.

dnotes’s picture

Here is a small patch to apply if you have already applied the patch from #2835995: Support loading selectize.js through CDNJS as well as the first patch from this issue. However, this will NOT work without both of the previous patches, so don't try to apply this one on its own. If you're applying all the patches I've uploaded this evening, which should resolve all outstanding 7.x issues, the order would be:

https://www.drupal.org/files/issues/2835995-1-selectize-7.x-support-cdn....
https://www.drupal.org/files/issues/2769929-3-selectize-7.x-404-on-confi...
https://www.drupal.org/files/issues/2835973-1-selectize-support-field-ap...
https://www.drupal.org/files/issues/2835973-2-selectize-7.x-support-fiel... (this patch)

kevinquillen’s picture

dnotes thanks for posting the patches. I've looked through the other posts and agree the functionality should exist in both versions. I have given you commit access so you can work further on this.

dnotes’s picture

StatusFileSize
new10.91 KB

Wow, commit access! I haven't really worked together with others on d.o projects before this - all mine are pretty much solo - but I'm happy to try it. If it were my own project, I would go ahead and commit those patches to 7.x-1.x. Then perhaps I could mark the new feature issues as 8.x issues, and port them forward instead of backward. Does that sound ok? Have you reviewed the patches and are you comfortable with them?

Also here is a new patch to replace the first one in this thread - in selectize.js, I forgot to check that Drupal.settings.selectizeFields existed before trying to iterate over it, so if you had a selectize FormAPI element on a page with no selectized FieldAPI fields, the javascript would error out.

garamani’s picture

@dnotes

First let me appreciate your hard work to make this module usable.

I patched all the codes by the patches you mentioned in this issue. The options available in filed setting page after patching are the best options that are not available in similar modules.

unfortunately after applying the patches, the list disappeared and there is only a text box with some css applied from the library.

-The selectize Library has been detected (based on Status Report).

Is there any solution to make it work? any Idea? This module with your patches is so close to be a perfect option for select lists.