Name of module : Autocomplete Dependent Population

This module provides ability to populate dependent form elements of an autocomplete form element with proper values.
This module introduces "autocomplete_dependee" type form element which allows to create an autocomplete field.
You can define form elements which will be populated when the value from autocomplete suggestion is selected. This
form elements can be of following type:

Textfield
Textarea
Dropdown
Radio button
Checkboxes

A form can have multiple "autocomplete_dependee" type form elements.

link to its sandbox project : https://www.drupal.org/sandbox/debaryadas/2321803

Git : git clone --branch 7.x-1.x http://git.drupal.org/sandbox/debaryadas/2321803.git autocomplete_dependent_population

Reviews of other projects

https://www.drupal.org/node/2322511#comment-9061559
https://www.drupal.org/node/2322295#comment-9062455
https://www.drupal.org/node/2322189#comment-9062505
https://www.drupal.org/node/2321907#comment-9062623
https://www.drupal.org/node/2311531#comment-9065737

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

debaryadas’s picture

Issue summary: View changes
debaryadas’s picture

Assigned: debaryadas » Unassigned
PA robot’s picture

Status: Needs review » Needs work

There are some errors reported by automated review tools, did you already check them? See http://pareview.sh/pareview/httpgitdrupalorgsandboxdebaryadas2321803git

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.

debaryadas’s picture

Issue summary: View changes
debaryadas’s picture

Issue summary: View changes
debaryadas’s picture

Issue summary: View changes
debaryadas’s picture

debaryadas’s picture

Issue summary: View changes
debaryadas’s picture

Issue summary: View changes
Status: Needs work » Needs review
Issue tags: +PAreview: review bonus

I am changing the status to "Needs Review" because I have resolved all issues mentioned at

http://pareview.sh/pareview/httpgitdrupalorgsandboxdebaryadas2321803git

The automated test cases have not been included yet since it is not mandatory. I am working on it. I will include it very soon.

With Regards
Debarya Das

debaryadas’s picture

debaryadas’s picture

Issue summary: View changes
debaryadas’s picture

Issue summary: View changes
potop’s picture

I think you should consider creating submodule with your example form.
Otherwise anyone who enables your module gets www.example.com/autocomplete_dependent_test_one url exposing your testing form to every user and there's no way to disable it without disabling the whole module.

Another thing which is not clear from your example is should all possible dependent elements data be returned in every call of autocomplete_dependent_population_test_one_callback() -- which could cause excessive database calls in many scenarios.

And why do you require widget type ('textfield', 'textarea', 'select') to be specified in returned data array, if you can easily determine it by widget name on the clientside?

potop’s picture

Status: Needs review » Needs work
debaryadas’s picture

Hi potop,

Thanks for reviewing my module and providing valuable suggestions. I will obviously develop an example module which will elaborate the usage of the main module with examples and can be disabled separately.

You do not need to send every possible values from 'autocomplete_dependent_population_test_one_callback'.
It is just an example which shows that every possible form element value can be returned. It is totally dependent on your application and business requirements. You can return a single value or more than that. I am thinking to split this example into separate part to enhance it's usability.

Obviously the widget type can be determined from client side and that is not a complicated task. But my purpose of building this module is to provide a generic way to populate the dependent fields of an autocomplete field without doing any javascript/jquery work. You can use this module for any form and populate the dependent fields without doing any javascript/jquery work. All you need to do is to return elements as specified in the examples.

If you have any other suggestions, you can provide. I will request you to review my module again after the changes.

With Regards
Debarya Das

debaryadas’s picture

Status: Needs work » Needs review

Hi,

Please take update the module from git and review it again. Clear the cache also.

With Regards
Debarya Das

pkamerakodi’s picture

Manual review comments:

Some minor review comments

1) Please add line break before return statments.
2) In autocomplete_dependent_population_process its better to add a isset every where it is accessing the element variable properties to avoid warnings
3) May be in theme function theme_autocomplete_dependee_field you can use drupal7 renderable array concept which way anyone using module can override the theme easily. And moreover output variable is unnecessary there, instead you return the element directly.
4) May it is better to implement hook_requirments and set the check for required library presence.
5) A small drupal standards formatting issue js doesnot follow 2 spaces per tab setting. Apart from that there are some formating issue like space after if etc.
For ex as below
jQuery.each(response['data'], function(index , value) {
cust_id[count] = index;
count ++;
});

6) And also could please try modularizing the js code since it is difficult to understand.

Please let me know if you need more info.

Regards,
Prajwal

pkamerakodi’s picture

Status: Needs review » Needs work
debaryadas’s picture

Status: Needs work » Needs review

Hi Prajwal,
Thanks for your detailed review of my project. Here are the changes

1] Done.

2] Done.

3] hook_element_info already provides a prepackaged default render arrays. So does it really
needed to build a renderable array inside theme function theme_autocomplete_dependee_field.
If you explain it then it will be better.

4] Done.

5] I have checked that Drupal suggests indentation with 2 spaces(https://www.drupal.org/node/172169#indenting) .
Moreover, Drupal javascript coding standards mentions "Control statements MUST have one space between the control
keyword and opening parenthesis, to distinguish them from function calls." (https://www.drupal.org/node/172169#structures).

It will be helpful if you suggest how to test javascript formatting.

I have changed the variable declaration format for few variables for javascript(like keyup_fields is modified to keyupFields)

6] The functionality is dependent on JS code. So it is not possible to modularize JS code totally. But I
will consider re-organizing code to reduce complexity if possible.

Any more suggestions will be helpful.

With Regards
Debarya

ram0108’s picture

Hello Debarya,

Thank for your contribution.

At the time of module installation i am getting following errors.
1 - Notice: Undefined offset: 0 in autocomplete_dependent_population_requirements() (line 16 of /opt/lampp/htdocs/drupal/sites/all/modules/autocomplete_dependent_population/autocomplete_dependent_population.install).

2- Jquery UI Autocomplete is not available.

If There is any kind of dependency on Jquery UI Autocomplete, Then you must describe it on requirement doc as well as info file.

Thanks!!

ram0108’s picture

Status: Needs review » Needs work

Please fix these two issue mentioned in previous comments.

debaryadas’s picture

Status: Needs work » Needs review

Hi ram,

Thanks for your help in detecting the issue. I have added additional code to prevent the errors. Few things that I want to mention is the following:

This module is dependent over misc/ui/jquery.ui.autocomplete.min.js which is shipped with drupal core. So there is less possibility that this file will be unavailable unless tampered/removed in any way. But I have placed a checking for this file inside hook_requirements in the install file. Moreover, is there any way to mention the a particular js file dependency in the .info file?

I request you to check your misc/ui for jquery.ui.autocomplete.min.js at your drupal 7 installation.

It will be helpful if you try again to install the module.

With Regards
Debarya Das

ram0108’s picture

Hello Debarya,

If Jquery UI Autocomplete is already available in Drupal core installation then there is no need to put this in info file. however i got error at the time of module installation, may be due to path which you wrote in your code, dont know exactly.

Today i will try again with your module.

Thanks!!

mpdonadio’s picture

Assigned: Unassigned » mpdonadio

Assigning to myself for next review.

mpdonadio’s picture

Status: Needs review » Reviewed & tested by the community

Automated Review

Review of the 7.x-1.x branch (commit b50e8e0):

  • No automated test cases were found, did you consider writing Simpletests or 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. You can also use the online version to check your project. You have to get a review bonus to get a review from me.

Manual Review

Individual user account
Yes: Follows the guidelines for individual user accounts.
No duplication
Yes: Does not cause module duplication and fragmentation.
Master Branch
Yes: Follows the guidelines for master branch.
Licensing
Yes/No: Follows the licensing requirements
3rd party code
Yes/No: Follows the guidelines for 3rd party code.
README.txt/README.md
Yes: Follows the guidelines for in-project documentation and the README Template.
Code long/complex enough for review
Yes: Follows the guidelines for project length and complexity.
Secure code
Yes/No. If "no", list security issues identified.
Coding style & Drupal API usage
Why are you using the global jQuery object instead of the $ paramater to the closure? Also, you need to use the context and settings that get passed to the behavior.

The formatting in the JS does not meet Drupal coding standards. See https://www.drupal.org/coding-standards

The JS needs more comments to describe what is going on. It is very hard to read.

If jquery.ui.autocomplete.min.js is part of core, why are you checking for it in a hook_requirements()?

You can use #attached for your settings, too, instead of drupal_add_js().

drupal_static is preferred over the native static in PHP.

(+) autocomplete_dependent_population_process will clash with hook_process. You need to rename this.

(+) Avoid linebreaks in translated strings.

(+) Your example menu paths should have access controls on them, 'access content' at the very least.

(+) You have a decent amount of bad formatting. I am not sure why the automated tests didn't pick them up. Read through the coding standards and try to use an IDE that is Drupal coding standard aware (like PhpStorm or Aptana).

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.

There are some big things that need to be addressed, but none are critical blockers, so I am setting RTBC. I want a second review by another admin on this because I have a feeling that I may have missed something.

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.

mpdonadio’s picture

Assigned: mpdonadio » Unassigned

Forgot to unassign myself.

debaryadas’s picture

Hi,

I have resolved issues mentioned in the previous post.

Please take a update from git and review it again.(Clear cache also)

With Regards
Debarya Das

er.pushpinderrana’s picture

Assigned: Unassigned » er.pushpinderrana

Assigning to myself for next review.

er.pushpinderrana’s picture

Assigned: er.pushpinderrana » Unassigned
Status: Reviewed & tested by the community » Fixed

Automated Review

Review of the 7.x-1.x branch (commit 06c4901):

This automated report was generated with PAReview.sh, your friendly project application review script. You can also use the online version to check your project. You have to get a review bonus to get a review from me.

Manual Review

(+) autocomplete_dependent_population_generate_element(): could you document @return here so that is clear what comes out of this function? See @return: Function return values

(+) autocomplete_dependent_population.js: Some comments length exceeding 80 characters, all comments must be under 80 characters read https://www.drupal.org/node/1354 again.

(+) autocomplete_dependent_population.js: you are encoding this value twice.

var input = Drupal.encodePath(Drupal.checkPlain($.trim($(this).val())));, I think Drupal.encodePath should be enough.

Remove extra space from count ++;.

Remove extra comma & space from // Remove the last , from autocompleteDependeeFields.

Project Page: Extend this little bit more, better to go through Tips for a great project page again.

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.

Not seeing any blocking issues here, also issues mentioned by other admins have been addressed.

Inline comments and code formatting looks good now.

Thanks for your contribution, debaryadas!

I updated your account so you can promote this to a full project and also create new projects as either a sandbox or a "full" project.

Here are some recommended readings to help with excellent maintainership:

You can find lots more contributors chatting on IRC in #drupal-contribute. So, come hang out and stay involved!

Thanks, also, for your patience with the review process. Anyone is welcome to participate in the review process. Please consider reviewing other projects that are pending review. I encourage you to learn more about that process and join the group of reviewers.

Thanks to the dedicated reviewer(s) as well.

debaryadas’s picture

Hi er.pushpinderrana,
Thanks for reviewing my project . I have made final changes mentioned by you.

Thanks to all the reviewer for reviewing my code.

With Regards
Debarya Das

Status: Fixed » Closed (fixed)

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