Chained drop down is a very simple/lightweight Chained Select/Dropdown widget for taxonomy term reference field.
How to use:
1) install the module;
2) add a taxonomy term reference field to any entity, choose "select list" as widget;
3) chained select will be automatically apply to the multi-level vocabulary.

Other modules do the same task: Hierarchical Select , Simple hierarchical select, but as we all known hierarchical select is too heavy to use and require additional click to function, from the user experience level, it is not good. the simple hierarchial select is claimed only work on node forms and as Views exposed filter.

Chained dropdown works on any taxonomy term reference field attached to any entity.

Sandbox project page: https://www.drupal.org/sandbox/ricson/2301987

git clone command: git clone --branch 7.x-1.x git://git.drupal.org/sandbox/ricson/2301987.git chained_dropdown

Comments

gwprod’s picture

Please include your git clone command (not the personal one, but the general purpose one)

PA robot’s picture

Status: Needs review » Needs work

Git clone command for the sandbox is missing in the issue summary, please add it.

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.

ricsonhoo’s picture

Issue summary: View changes
ricsonhoo’s picture

Status: Needs work » Needs review

adding git clone command.

David Witczak’s picture

Hello,
please use pareview.sh

I tested your module, if I selected a childless term , the second list does not change and displays the wrong term

ricsonhoo’s picture

@David Witczak, thank you for your report, the problem will be fixed ASAP.

daniel.moberly’s picture

Status: Needs review » Needs work

Fails automatic tests:

http://pareview.sh/pareview/httpgitdrupalorgsandboxricson2301987git

Primarily small issues with formatting, but you also have the following issues:
Missing README file
Need to clean up your .info file - remove everything after "dependencies" lines

ricsonhoo’s picture

Status: Needs work » Needs review

README.txt added, .info file cleaned up, .module file formatted.

pushpinderchauhan’s picture

Status: Needs review » Needs work
StatusFileSize
new4.68 KB
new7.7 KB

@ricsonhoo, first of all thanks for your contribution.

Your above mention git command is incorrect, it should be:
git clone --branch 7.x-1.x http://git.drupal.org/sandbox/ricson/2301987.git

Following modules looks like similar to your module.

  1. Hierarchical Select
  2. Simple hierarchical select

Please add your comment on this.

Manual Review:

1. Also I tested your module if I make multi-level hierarchy with different-2 number of child as shown below:
taxonomy

Now It is appearing in content type form as shown below:
Content type field

2.Some garbage value is coming in comments.

 for ($i = 0; $i < $depth; $i++) {
    // 获得本select的所代表的depth�parent

3. Better to keep following code in separate js file and use Drupal.settings with drupal behaviors.

$js = <<<EOL
    (function($, Drupal) {
      Drupal.behaviors.chained_dropdown = {
        attach: function(context, settings) {
        //our js goes here
         var default_options_string_$widget_id = "$default_options_string";
         var all_options_$widget_id = $all_options;
         target_select = $("select[datasource=$widget_id][depth="+ $depth +"]");
         selected_value = target_select.val();
         target_select.empty().append(default_options_string_$widget_id);
         target_select.val(selected_value);
         last_select = $("select[datasource=$widget_id][depth=$depth]").find("option");
         if (!last_select.length){
           copied_val = $("select[datasource=$widget_id][depth=$up_depth]").val();
           copied_txt = $("select[datasource=$widget_id][depth=$up_depth]").find("option:selected").text();
           copied_option = '<option value="'+copied_val+'">'+copied_txt+'</option>';
           $("select[datasource=$widget_id][depth=$depth]").append(copied_option).hide();
         }
         $('.chained-dropdown').change(function(){
            eval('var data_source = all_options_' + $(this).attr('datasource'));
            depth = (parseInt($(this).attr('depth'))+1);
            value = $(this).val();
            //console.log(depth);
            //console.log(value);
            var new_options_data = {};
            var new_options = '';
            eval('new_options_data = data_source._'+ depth + '._' + value);
            var childless = false;
            if (typeof(new_options_data) == "undefined") {
              childless = true;
              current_val = $(this).val();
              current_txt = $(this).find("option:selected").text();
              eval('new_options_data = {'+ current_val +':"'+current_txt+ '"};');
            }

            $.each(new_options_data, function(key, text){
                new_options += '<option value="'+key+'">'+text+'</option>';
            });
            
            child_select = $("select[datasource="+ $(this).attr('datasource') +"][depth="+ depth +"]");
            child_select.empty().append(new_options);
            if (childless){
              child_select.hide();
            }else{
              child_select.show();
            }
           

         });


        }
       };
    }(jQuery, Drupal));
EOL;
  drupal_add_js($js, array(
    'type' => 'inline',
    'scope' => 'footer',
    'weight' => 5,
    )
  );

4. There is only one function in your .module file, better to break this function code in sub functions, hard to read and debug.
5. hook_help() is also missing in your module.
6. Project page description is too small.

Thanks Again!

ricsonhoo’s picture

@er.pushpinderrana thank you for your test and review, will fix it asap.

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.