This module registers a Chosen Select form element that could be flexibly used on any form and also provides a powerful field widget for all kinds of lists. It uses Select2 jQuery plugin and has several options that helps to control drop down style.

Chosenselect

http://drupal.org/sandbox/ann.matrosova/1817534
git clone http://git.drupal.org/sandbox/ann.matrosova/1817534.git chosen_select
For Drupal 7.

CommentFileSizeAuthor
#8 ugly tags.png2.52 KBpere orga
#8 always searching.png4.32 KBpere orga

Comments

adamelleston’s picture

Status: Needs review » Needs work

Hi,

There is already a chosen field. From a quick glance they seem very similar. If your project is clearly different then can you update your project page and explain the differences.

http://drupal.org/project/chosen

sreynen’s picture

Hi ann.matrosova,

Thanks for your contribution. I did a manual review and it looks pretty good in general, but I noticed a few issues:

1. I think chosenselect_autocomplete() should look a bit more like taxonomy_autocomplete(), specifically in the way you're loading arguments. Directly referencing $_GET is pretty rare in PHP code.

2. chosenselect_autocomplete() returns plain text on an error but JSON on success. I didn't see anything in the JavaScript suggesting it would handle these different response formats, but maybe that's in the Select2 plugin. I'm not sure this is a problem, but it looks like it might be, so maybe you can confirm this is how the JavaScript expects errors?

3. There's some TODO comments in the JavaScript. These should be done before a release.

The automated review also found some code formatting issues. Nothing there looks very important, but worth fixing anyway.

kevinquillen’s picture

Sounds like the major difference between the two projects is Chosen integrates the jQuery plugin into the Drupal admin UI so you can enter classes you want Chosen to apply itself to, whereas this module wants to make it available as a new FormAPI element.

sreynen’s picture

This module also uses Select2, which seems to be a fork of the Chosen plugin. So changing the name of the project might be good to reduce confusion between the two. Describing the differences in the project description is important either way.

vineet.osscube’s picture

Hi,
I suggest you to take a look at this page:

http://ventral.org/pareview/httpgitdrupalorgsandboxannmatrosova1817534git

Here you can check source code whether it meets drupal coding standards or not, and advise you what to change in your code. You can repeat review after your commits, and can fix those errors.

ann.matrosova’s picture

Status: Needs work » Needs review

Hi,

Module Chosen select has some advantages:
- You can create your custom form element ('#type' => 'chosenselect'). It is not only a widget plugin
- It has an autocomplete taxonomy reference widget.
- It is based on Select2 library (http://ivaynberg.github.com/select2/) which is more powerful than Chosen library
- And our js files are loading only in cases where they are needed, not on every page

Thank you for issues.
We use $_GET because implementation is different from taxonomy autocompletion, if you ment to provide a security on using $_GET, on last commit filter_xss() function was applied.
And about JSON response, it is just Select2 implementation.

pere orga’s picture

If this module doesn't use the Chosen library why do you put the word 'chosen' in its name?

pere orga’s picture

StatusFileSize
new4.32 KB
new2.52 KB
  • Ideally, the module should warn you if the required file select2.js is not found.
  • I think you should add:
    div.select2-search input {
      width: 100%;
      box-sizing: content-box;
    }

    inside css/chosenselect_block.css. Otherwise in some themes (such as the default theme in Commerce Kickstart) the field is not displayed correctly (see screenshot).

  • I don't know if this is a limitation of Select2.js, but shouldn't the input field be degraded to a select list if javascript is disabled?
  • It seems that the search is not working in my Commerce Kickstart clean installation. As you can see in the screenshot, I always see "Searching...", even if there are existing tags or not. I expected to see the matching tags, or a text like "no available records"...
pere orga’s picture

Status: Needs review » Needs work
ardas’s picture

Dear Pere,

1. JS degrade feature will be developed later. It is not very important feature since everybody today has JS even mobiles support it. So, this is a very low priority.

2. We didn't test this module with Commerce Kickstart as well as other open Drupal builds. We realize that there may be several conflicts but it is a matter of time we can invest right now into development.

We want to launch this module into community and give people ability to start using it. Later on, we will gather requirements and be improving it. So, lets start with some version that will satisfy many people as it is now.

Thank you for your help and review!

ann.matrosova’s picture

Status: Needs work » Needs review

Hi,
I've fixed two first issues. Now user gets a message that select2.js file is not found. And added into css file:
box-sizing: content-box;

ardas’s picture

Status: Needs review » Needs work

Because Chosen sounds like a normal name that is quite famous today. Select2 doesn't mean anything.. it is too technical and not user-friendly. Our module behaves like Chosen and it is important to make its name self explanatory.

Can you imagine this:
$form['myselect']['#type'] = 'select2';

As for me it sounds strange... no semantic in 'select2' naming at all.

The module uses another library but who cares? Developers just need to create a 'chosenselect' element.

And what if tomorrow Select2 will be stopped in favor of a more powerful Select3 component like it usually happens in open source community? We will just change a library but keep the API the same.

The main point for us was how people would use the form element. We think 'chosenselect' is a good name for a form element.

klausi’s picture

Status: Needs work » Closed (won't fix)

Closing due to lack of activity. Feel free to reopen if you are still working on this application.

If you reopen this please keep in mind that we are currently quite busy with all the project applications and I can only review projects with a review bonus. Please help me reviewing and I'll take a look at your project right away :-)

klausi’s picture

Issue summary: View changes

Edit description.