I have a profile form with multiple instances of a 'Location' vocabulary. I need most instances to be a standard, 'select deepest' and that works fine, until i set on instance to 'dropbox' whats happening is all instances of location are getting the drop box on display.

Am i configuring something incorrectly or is it a bug?

EDIT: (Before even posting) In further investigation has shown that all my instances of 'location' are using the same config.

p.s. this officially counts as the most complex module i have (so far) tried to debug.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Wim Leers’s picture

Status: Active » Postponed (maintainer needs more info)

Are you using alpha 4 or a dev snapshot that's newer than alpha 4?

I don't know *how* you're adding multiple instances. How are you configuring just one of them to get the dropbox?

P.S.: Hehe. Yes. It's very complex. It's the simple UI that matters! But it of course needs to *work* first…

arcticShadow’s picture

EDIT: I should answer your questions.
I'm getting multiple instances as follows.

  • Using Drupal 7 people->account settings->manage fields.
  • Adding a term reference, with widget setup to use HS
  • adding another term reference, with a different field name, using the same vocabulary
  • setting the second term reference to use HS widget

Then if i enable 'dropbox' on one widget settings, it enables it on the other as well. (sometimes. it seems dependent that i actually view the two HS fields on the front end of the site before the settings sync)

It's a really weird thing. I can try and get more details when i have some more time if needed.

I just double checked the version i'm using. It was labeled as 7.x-3.x-dev in the .info file. I may have gone backwards now, but i have used drush to get alpha5 minutes ago. I'll see if i can still reproduce my issue and get back to you.

Wim Leers’s picture

Title: Issue or Support Request? multiple field of the same vocabulary with dropbox » Allow different HS configs for different Taxonomy Term fields (instead of 1 HS config per vocabulary)
Component: Code » Code - Taxonomy
Category: support » feature
Priority: Normal » Minor
Status: Postponed (maintainer needs more info) » Postponed

The same field should get the same widget. However, you seem to be using different fields. Correct?

This is simply not supported yet. Currently, only one configuration is supported per vocabulary. This is fairly easy to add though. Patch is welcome.

arcticShadow’s picture

That would make sense on my end. For the time being Ill have to leave the patching in this respect, a standard multi select element will have to suffice.

axiom3279’s picture

FileSize
4.73 KB

I wrote a quick patch for this issue -- I am on a windows eclipse system so please someone clean up patch as needed. All I am doing on the patch is changing the id to a unique id per field (from taxonomy - vid to taxonomy - vid - fieldid). I did also find an issue with how unlimited is handled, shouldn't the drop box be enabled by default when someone chooses unlimited, or am I missing something? Can't wait for hs4. Willing to help.

seanreiser’s picture

patch worked like a charm axiom3279 Thanks!

adrien.felipe’s picture

I am trying to do the same (have several HS configs for the same vocab). I will try to "hack" this with a feature and see what hapens, but is this ported to dev version or going to be at some point?
Now that we have a patch!

chirhotec’s picture

Same problem.

I'm have two different fields on two different node types, but are using a common Taxonomy.

retiredpro’s picture

axiom3279's method of appending the file id worked for me too. I can now set and save two separate widget configurations. Thanks!

Kars-T’s picture

Priority: Minor » Normal
Status: Postponed » Needs work

Hi

this is a multiply requested issues and quiet an annoyance using HS.

The patch has some coding style issues that should be fixed first. Please rework it for the latest dev.

And in the long run imho we shouldn't use variables for the settings but put it in field API.

one_orange_cat’s picture

Issue summary: View changes
Status: Needs work » Needs review
FileSize
11.69 KB

I have created a new patch which hopefully resolves this problem against the latest dev build using the same principle detailed in #5 but using machine_names instead of ids. This is due to features related issues and follows on from, and builds on, the patch in https://www.drupal.org/node/1477292#comment-7893157.

I agree that these settings could probably move out of variables altogether but given the work already carried out in the features machine_name patch I have continued on that line for now. Hopefully this patch will help someone else out.

Georgique’s picture

Status: Needs review » Needs work

Patch is fine, it works well. Though it still need to be reworked against latest dev.

Georgique’s picture

Btw shoudln't we rework update function?

Georgique’s picture

Version: 7.x-3.x-dev » 7.x-3.0-alpha12
Status: Needs work » Needs review
FileSize
9.28 KB

I guess we should force this issue - it is VERY important.
I've rerolled patch against the latest alpha12, it successfully work on my install for a while. Please review.

stefan.r’s picture

Looks good but doesn't this needs an update hook for backwards compatibility?

Also comments should start with an upper-case letter and end with a full stop (as well as sticking to 80 characters per line).

Georgique’s picture

Status: Needs review » Needs work

Yes, will improve comments and make update function.

Georgique’s picture

Improved comments and introduced update function. Update function was tested as a separated code, not as an update function, so needs community's review.

stefan.r’s picture

  1. +++ b/includes/common.inc
    @@ -12,7 +12,7 @@
    - *   "taxonomy-vocab_machine_name".
    

    "taxonomy-vocab_machine_name-field_name" is not a very good example of "module-someid" as someid has a dash in it. Maybe use an example from another submodule?

  2. +++ b/modules/hs_taxonomy.module
    @@ -170,7 +168,7 @@ function hs_taxonomy_form_taxonomy_form_term_alter(&$form, &$form_state) {
    -    'level_labels'    => $vocabulary_config['level_labels'],
    +    'level_labels'    => array('status' => FALSE, 'labels' => array()),
    

    Just to be clear, why was this replaced?

  3. +++ b/modules/hs_taxonomy.module
    @@ -1097,16 +1105,67 @@ function _hs_taxonomy_hierarchical_select_get_tree($vid, $parent = 0, $depth = -
    + */
    +function hs_taxonomy_get_config_id(stdClass $vocabulary, $field_name) {
    +  return "taxonomy-{$vocabulary->machine_name}-{$field_name}";
    +}
    +
    

    If it is possible for the machine name/field names to have dashes, the separator here may have to be a double dash in order to prevent duplicate config IDs?

Georgique’s picture

1. Agree. I just use only hs_taxonomy, but will look for an another example.
2. Earlier we had one config per vocab. Thus when we added HS functionality to "Parent" field in taxonomy term edit form, we could use vocab config for it. Actually only level labels were used. New concept is one config per field = multiple configs per vocab. Thus we just use default empty settings, that's why I've replaced this.
3. Only underscore is allowed for fieldnames. Same for vocabulary name.

stefan.r’s picture

Cool I'll be happy to commit this once this has had some further review.

What makes you think the update hook would be problematic as an update hook as opposed to as a separate function? :)

Georgique’s picture

I don't think it WOULD be problematic, I just think it CAN be problematic because I just don't have old-style configs on my install. Although code is quite simple and clear, I would be happy if smbd can test it on machine where there are old-style configs and report about results.

rcodina’s picture

Patch on #17 works for me. Many thanks!

I updated from alpha9 to 7.x-3.0-alpha12+1-dev with patch #17 of this issue applied (I also applied patch 6 on issue 1169486). I executed update.php and all went ok. I just lost one setting from my old HS configuration: The "Enable the dropbox" checkbox was checked before update and now is unchecked.

Georgique’s picture

@stefan.r Just took a look into the code and found only 2 types of config id: taxonomy-vocab_id-fieldname and taxonomy-views-viewname-displayid-filterid (which is even worse for our case). Thus I suggest just to simplify that comment guessing that developers are smart enough and can find examples of config ids when implementing their sub-modules. Patch is attached.

@rcodina Thanks for testing and reviewing, but strange! I do nothing with configs, just getting it and saving under new id.

I guess the patch needs some more testing after #22, so problem described there should be either confirmed or disproved.

stefan.r’s picture

Status: Needs review » Needs work

Yes, losing settings would be problematic!

@rcodina can you debug the update hook and see how that setting got lost?

stefan.r’s picture

Priority: Normal » Critical

@rcodina did you have multiple allowed vocabularies on any fields? It seems the module will get the settings from the "first defined" vocabulary in the allowed vocabularies (with index 0), whereas the update hooks will loop through all the allowed vocabularies for a specific term reference field and mistakenly attempt to get the settings from every of the vocabulary (instead of only from the first one).

@Georgique so in the update hook, instead of doing $vocabulary_name = $allowed_value['vocabulary'];
it should likely do $vocabulary_name = $allowed_values[0]['vocabulary'];

Further, not to complicate things to much, we should probably should stick to defining settings on just a per-field level (instead of a combination of field and term). That way the config ID would become just taxonomy-{$fieldname} instead of taxonomy-{$vocabulary_name}-{$fieldname}. This would also solve the issue in #2393341: Hierarchical Select Taxonomy can break node/field/widget edit pages for term references with nonexistent/undefined allowed vocabularies (which occurs when there is no existing allowed vocabulary defined for a field). That issue is critical, and as this issue is now a dependency, I am upgrading the priority of the current issue.

stefan.r’s picture

stefan.r’s picture

Status: Needs work » Needs review
FileSize
9.88 KB
8.69 KB

  • stefan.r committed 7e83ccf on
    Issue #1280994 by Georgique, stefan.r, axiom3279, one_orange_cat: Allow...
Georgique’s picture

I believe we should delete configs with old ID. Since the code is committed and new version was released, I suggest to create one more update hook cleaning up old configs.

Georgique’s picture

Status: Needs review » Needs work
stefan.r’s picture

Yes, I agree. I took out the config deletion so we could still recover the old configs in a next release in case there were still any problems with the update hook.

If in a couple of weeks no-one reports any issues, we'll add an update hooks that removes the old configs.

Georgique’s picture

Status: Needs work » Needs review
FileSize
1.01 KB

I see. Well, for me update hook works well, if there are no new issues about update hook, we can apply this patch.

stefan.r’s picture

We'd want to delete "taxonomy-{$vocabulary_name}", not "taxonomy-{$vocabulary_name}-{$field_name}" right?

The latter would only apply to those who have any of the old patches (before #27) in this issue, not to any dev versions or releases.

Georgique’s picture

Oops, sure. Here is right patch.

Georgique’s picture

FileSize
666 bytes

Fixed comment.

stefan.r’s picture

Status: Needs review » Reviewed & tested by the community

OK let's leave this for a few weeks until we confirm there are no problems with people losing their config in the previous update hook (from alpha13).

stefan.r’s picture

Priority: Critical » Normal

Lowering priority as this is just about an update hook anymore.

stefan.r’s picture

Status: Reviewed & tested by the community » Fixed

Added update hook.

  • stefan.r committed 3141086 on 7.x-3.x authored by Georgique
    Issue #1280994 by Georgique, stefan.r, axiom3279, one_orange_cat: Allow...

Status: Fixed » Closed (fixed)

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