Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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.
Comment | File | Size | Author |
---|---|---|---|
#35 | hs-configs_cleanup-1280994-35.patch | 666 bytes | Georgique |
#27 | hs-config_per_fieldname-1280994-27.patch | 8.69 KB | stefan.r |
#27 | interdiff.txt | 9.88 KB | stefan.r |
#23 | hs-config_per_fieldname-1280994-23.patch | 10.76 KB | Georgique |
#17 | hierarchical_select-taxonomy_config_per_field-1280994-17.patch | 10.74 KB | Georgique |
Comments
Comment #1
Wim LeersAre 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…
Comment #2
arcticShadow CreditAttribution: arcticShadow commentedEDIT: I should answer your questions.
I'm getting multiple instances as follows.
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.
Comment #3
Wim LeersThe 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.
Comment #4
arcticShadow CreditAttribution: arcticShadow commentedThat 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.
Comment #5
axiom3279 CreditAttribution: axiom3279 commentedI 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.
Comment #6
seanreiser CreditAttribution: seanreiser commentedpatch worked like a charm axiom3279 Thanks!
Comment #7
adrien.felipe CreditAttribution: adrien.felipe commentedI 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!
Comment #8
chirhotec CreditAttribution: chirhotec commentedSame problem.
I'm have two different fields on two different node types, but are using a common Taxonomy.
Comment #9
retiredpro CreditAttribution: retiredpro commentedaxiom3279's method of appending the file id worked for me too. I can now set and save two separate widget configurations. Thanks!
Comment #10
Kars-T CreditAttribution: Kars-T commentedHi
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.
Comment #11
one_orange_cat CreditAttribution: one_orange_cat commentedI 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.
Comment #12
Georgique CreditAttribution: Georgique commentedPatch is fine, it works well. Though it still need to be reworked against latest dev.
Comment #13
Georgique CreditAttribution: Georgique commentedBtw shoudln't we rework update function?
Comment #14
Georgique CreditAttribution: Georgique commentedI 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.
Comment #15
stefan.r CreditAttribution: stefan.r commentedLooks 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).
Comment #16
Georgique CreditAttribution: Georgique commentedYes, will improve comments and make update function.
Comment #17
Georgique CreditAttribution: Georgique commentedImproved comments and introduced update function. Update function was tested as a separated code, not as an update function, so needs community's review.
Comment #18
stefan.r CreditAttribution: stefan.r commented"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?
Just to be clear, why was this replaced?
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?
Comment #19
Georgique CreditAttribution: Georgique commented1. 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.
Comment #20
stefan.r CreditAttribution: stefan.r commentedCool 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? :)
Comment #21
Georgique CreditAttribution: Georgique commentedI 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.
Comment #22
rcodina CreditAttribution: rcodina commentedPatch 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.
Comment #23
Georgique CreditAttribution: Georgique commented@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.
Comment #24
stefan.r CreditAttribution: stefan.r commentedYes, losing settings would be problematic!
@rcodina can you debug the update hook and see how that setting got lost?
Comment #25
stefan.r CreditAttribution: stefan.r commented@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.
Comment #26
stefan.r CreditAttribution: stefan.r commentedComment #27
stefan.r CreditAttribution: stefan.r commentedComment #29
Georgique CreditAttribution: Georgique commentedI 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.
Comment #30
Georgique CreditAttribution: Georgique commentedComment #31
stefan.r CreditAttribution: stefan.r commentedYes, 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.
Comment #32
Georgique CreditAttribution: Georgique commentedI see. Well, for me update hook works well, if there are no new issues about update hook, we can apply this patch.
Comment #33
stefan.r CreditAttribution: stefan.r commentedWe'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.
Comment #34
Georgique CreditAttribution: Georgique commentedOops, sure. Here is right patch.
Comment #35
Georgique CreditAttribution: Georgique commentedFixed comment.
Comment #36
stefan.r CreditAttribution: stefan.r commentedOK 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).
Comment #37
stefan.r CreditAttribution: stefan.r commentedLowering priority as this is just about an update hook anymore.
Comment #38
stefan.r CreditAttribution: stefan.r commentedAdded update hook.