Synopsis

Inspired by Chosen Ajax which uses the Chosen jQuery plugin and a modified version of Ajax Chosen to make your autocomplete fields more user-friendly.

It supports auto-create option. It works with Entity reference field type only. All you need to do is set a Chosen Autocomplete option on Manage Form Display page.

Requirements

Chosen Library should be installed with Chosen module

Dependencies

Chosen Module

Known problems

Currently Chosen Module works with 1.6.1. library version.

How to use in Field UI

  • Create (or edit an existing field) which has Entity Reference type
  • Go to Manage Form Display page and select Chosen Autocomplete widget for this field.

Setting up this repository locally for the first time

git clone --branch 8.x-1.x https://git.drupal.org/sandbox/Gene/2831141.git chosen_autocomplete
cd chosen_autocomplete

Link to sandbox project https://www.drupal.org/sandbox/gene/2831141

Comments

EugeneChechel created an issue. See original summary.

EugeneChechel’s picture

Issue summary: View changes
PA robot’s picture

We are currently quite busy with all the project applications and we prefer projects with a review bonus. Please help reviewing and put yourself on the high priority list, then we will take a look at your project right away :-)

Also, you should get your friends, colleagues or other community members involved to review this application. Let them go through the review checklist and post a comment that sets this issue to "needs work" (they found some problems with the project) or "reviewed & tested by the community" (they found no major flaws).

I'm a robot and this is an automated message from Project Applications Scraper.

aloknarwaria’s picture

Category: Task » Feature request
Status: Needs review » Needs work

Module done there job but there is some UI issue whene I selected few elements.

EugeneChechel’s picture

Hi @aloknarwaria

Could you please be more exact? what UI issues you mentioned?

tvalimaa’s picture

I got Notice: Undefined index: #autocreate in Drupal\Core\Entity\Element\EntityAutocomplete::processEntityAutocomplete() if field setting "Create referenced entities if they don't already exist is off" is not turned on.

harsh.behl’s picture

HI I got similar notice: messageNotice: Undefined index: #autocreate in Drupal\Core\Entity\Element\EntityAutocomplete::processEntityAutocomplete() (line 119 of core/lib/Drupal/Core/Entity/Element/EntityAutocomplete.php).
when Create referenced entities if they don't already exist is checked off.

Also it is very slow to auto suggest options for ex: If I type test it takes 5-10 seconds to load.

itamair’s picture

I just made the https://pareview.sh run on your project sandbox, and found this

FILE: /root/repos/pareviewsh/pareview_temp/README.txt
----------------------------------------------------------------------
FOUND 0 ERRORS AND 3 WARNINGS AFFECTING 3 LINES
----------------------------------------------------------------------
3 | WARNING | Line exceeds 80 characters; contains 103 characters
8 | WARNING | Line exceeds 80 characters; contains 174 characters
10 | WARNING | Line exceeds 80 characters; contains 122 characters
----------------------------------------------------------------------

FILE: /root/repos/pareviewsh/pareview_temp/chosen_autocomplete.info.yml
--------------------------------------------------------------------------
FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 1 LINE
--------------------------------------------------------------------------
1 | WARNING | Remove "project" from the info file, it will be added by
| | drupal.org packaging automatically
1 | WARNING | Remove "version" from the info file, it will be added by
| | drupal.org packaging automatically
--------------------------------------------------------------------------

EugeneChechel’s picture

Status: Needs work » Needs review

Fixed Undefined index: #autocreate issue. Code sniffer issues with info.yml and README file have been fixed.

EugeneChechel’s picture

Priority: Normal » Major
cchanana’s picture

Hi EugeneChechel,

I just made the https://pareview.sh run on your project, and found this

FILE: /src/Plugin/Field/FieldWidget/ChosenAutocomplete.php
--------------------------------------------------------------------------
FOUND 0 ERRORS AND 3 WARNINGS AFFECTING 3 LINES
--------------------------------------------------------------------------
41 | WARNING | t() calls should be avoided in classes, use dependency
| | injection and $this->t() instead
53 | WARNING | t() calls should be avoided in classes, use dependency
| | injection and $this->t() instead
153 | WARNING | \Drupal calls should be avoided in classes, use
| | dependency injection instead

cchanana’s picture

Status: Needs review » Needs work
PA robot’s picture

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

Closing due to lack of activity. If you are still working on this application, you should fix all known problems and then set the status to "Needs review". (See also the project application workflow).

I'm a robot and this is an automated message from Project Applications Scraper.

EugeneChechel’s picture

Status: Closed (won't fix) » Needs work
PA robot’s picture

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

Closing due to lack of activity. If you are still working on this application, you should fix all known problems and then set the status to "Needs review". (See also the project application workflow).

I'm a robot and this is an automated message from Project Applications Scraper.

Ravi Cmsminds’s picture

Hi,

I checked your module and found some issues and recommendations that you may be interested in :

FILE: ...sh/pareview_temp/src/Plugin/Field/FieldWidget/ChosenAutocomplete.php
--------------------------------------------------------------------------
FOUND 0 ERRORS AND 3 WARNINGS AFFECTING 3 LINES
--------------------------------------------------------------------------
41 | WARNING | t() calls should be avoided in classes, use dependency
| | injection and $this->t() instead
53 | WARNING | t() calls should be avoided in classes, use dependency
| | injection and $this->t() instead
153 | WARNING | \Drupal calls should be avoided in classes, use
| | dependency injection instead
--------------------------------------------------------------------------

FILE: /root/repos/pareviewsh/pareview_temp/chosen_autocomplete.info.yml
--------------------------------------------------------------------------
FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
--------------------------------------------------------------------------
6 | WARNING | All dependencies must be prefixed with the project name,
| | for example "drupal:"
9 | WARNING | All dependencies must be prefixed with the project name,
| | for example "drupal:"
--------------------------------------------------------------------------

EugeneChechel’s picture

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

Fixed #11

sleitner’s picture

Category: Feature request » Task
Priority: Major » Normal
Status: Needs review » Needs work

Automated Review

Pareview details: https://pareview.sh/pareview/https-git.drupal.org-sandbox-gene-2831141.g...

Git errors:

Review of the 8.x-1.x branch (commit c6ffaf5):

  • Your README.txt does not follow best practices (headings need to be uppercase). See https://www.drupal.org/node/2181737 .
  • The chosen_autocomplete.module does not implement hook_help(). See https://www.drupal.org/docs/develop/documenting-your-project/module-docu... .
  • Coder Sniffer has found some issues with your code (please check the Drupal coding standards).
    
    FILE: ...src/Plugin/Field/FieldType/ChosenAutocompleteEntityReferenceItem.php
    --------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    --------------------------------------------------------------------------
     30 | WARNING | Possible useless method overriding detected
    --------------------------------------------------------------------------
    
    
    FILE: ...sh/pareview_temp/src/Plugin/Field/FieldWidget/ChosenAutocomplete.php
    --------------------------------------------------------------------------
    FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
    --------------------------------------------------------------------------
     5 | WARNING | [x] Unused use statement
     6 | WARNING | [x] Unused use statement
    --------------------------------------------------------------------------
    PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    --------------------------------------------------------------------------
    
    Time: 671ms; Memory: 4Mb
    
  • ESLint has found some issues with your code (please check the JavaScript coding standards). See attachment.
  • DrupalPractice has found some issues with your code, but could be false positives.
    
    FILE: ...sh/pareview_temp/src/Plugin/Field/FieldWidget/ChosenAutocomplete.php
    --------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    --------------------------------------------------------------------------
     155 | WARNING | \Drupal calls should be avoided in classes, use
         |         | dependency injection instead
    --------------------------------------------------------------------------
    
    Time: 346ms; Memory: 4Mb
    
  • No automated test cases were found, did you consider writing PHPUnit tests? This is not a requirement but encouraged for professional software development.

This automated report was generated with PAReview.sh, your friendly project application review script.

Manual Review

Individual user account
Yes: Follows the guidelines for individual user accounts.
No duplication
Yes: Does not cause module duplication and/or fragmentation.
Master Branch
No: Does not follow the guidelines for master branch. See pareview
Licensing
Yes: Follows the licensing requirements.
3rd party assets/code
No: Does not follow the guidelines for 3rd party assets/code. Use chosen in /libraries folder
README.txt/README.md
No: Does not follow the guidelines for in-project documentation and/or the README Template. See pareview
Code long/complex enough for review
Yes: Follows the guidelines for project length and complexity.
Secure code
Yes: Meets the security requirements.
Coding style & Drupal API usage
See pareview.

The starred items (*) are fairly big issues and warrant going back to Needs Work. Items marked with a plus sign (+) are important and should be addressed before a stable project release. The rest of the comments in the code walkthrough are recommendations.

If added, please don't remove the security tag, we keep that for statistics and to show examples of security problems.

This review uses the Project Application Review Template.

apaderno’s picture

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

If you are still working on this application, you should fix all known problems and set the status to Needs review. (See also the project application workflow.)
Please don't change status of this application if you aren't sure you have time to dedicate to this application, or it will be closed again as won't fix.

I am closing this application due to lack of activity.