Problem/Motivation

Chosen is a great way to make dropdowns with lots of options more user friendly. In SHS for Drupal 7 we had an integration for Chosen, which is currently not implemented.

Proposed resolution

Add a sub-module to SHS to integrate with chosen.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

stBorchert created an issue. See original summary.

jhedstrom’s picture

This is the issue that added support in 7.x #2084019: Support Drupal Chosen 7.x-2.0-alpha3 using Chosen v1.0 . Seems the code added to shs.js in that issue just didn't get ported at all to 8.x.

stBorchert’s picture

Due to the major rewrite for D8 (using backbone models and views) Chosen can be integrated in a much cleaner way as it had been in D7.
We already used this on a client site and simply have to cleanup the code and generalize some things so it can be added to SHS "core". :)

jhedstrom’s picture

Assigned: Unassigned » jhedstrom

I've got some time to work on this.

stBorchert’s picture

Assigned: jhedstrom » stBorchert

Uhm, no need for this. The integration is almost complete.
Thanks anyway ...

Sorry, I should have said this before :/

jhedstrom’s picture

@stBorchert no worries. Let me know if there's anything I can do to help.

stBorchert’s picture

Status: Active » Needs review
FileSize
27.66 KB

Ok, here it is.
@jhedstrom: I would be really glad if you can test the integration and have a look on thing I eventually could have done better :)

PS: you need to enable shs first and afterwards shs_chosen to make everything work. Simply installing shs_chosen does not work because of #2679008: Module weight is not taken into account after module installation.

Status: Needs review » Needs work

The last submitted patch, 7: shs-add_support_for_chosen-2712123-7.patch, failed testing.

The last submitted patch, 7: shs-add_support_for_chosen-2712123-7.patch, failed testing.

stBorchert’s picture

Status: Needs work » Needs review

Ah, testbot is right ... running tests strongly requires having some :/

jhedstrom’s picture

I tested this manually and it seems to work. I'm going to do some additional testing around site installs that use this new sub module.

+++ b/modules/shs_chosen/src/Plugin/Field/FieldWidget/OptionsShsChosenWidget.php
@@ -0,0 +1,127 @@
+      $summary[] = $this->t('Use !global_settings', ['!global_settings' => Link::createFromRoute('global chosen settings', 'chosen.admin')->toString()]);

I'm getting this warning due to the ! placeholder:

User error: Invalid placeholder (!global_settings) in string: Use !global_settings in Drupal\Component\Render\FormattableMarkup::placeholderFormat() (line 233 of core/lib/Drupal/Component/Render/FormattableMarkup.php).

Looking at system_requirements() I think links can be added by using :url placeholders.

stBorchert’s picture

FileSize
27.63 KB

Urgh, indeed. Don't know, why I used this here.

  • stBorchert committed 0a61336 on 8.x-1.x
    Issue #2712123 by stBorchert: Add support for chosen
    
stBorchert’s picture

Status: Needs review » Fixed

Committed the current integration into 8.x-1.x.
Please note that #2679008: Module weight is not taken into account after module installation is still valid so you have to enable shs first and shs_chosen afterwards.

  • stBorchert committed d76de22 on 8.x-1.x
    Issue #2712123 by stBorchert: Update README to reflect current state.
    

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.