trying to add any term through: admin/structure/taxonomy/my_vocab/add

error: Parents field is required.

disabling HS, everything works fine.

Comments

rajatgusain’s picture

@ kervi
This module works properly so no need to uninstall is just download most updated release, and try to add the parent.
It works fine for me.

rajat gusain

dgastudio’s picture

Status: Active » Closed (works as designed)

you are right Rajat. It was problem of Metatag module.

sorry.

brianV’s picture

Title: Parents field is required. » Taxonomy term 'Parents' field does not recognize '0' to mean '<root>'
Status: Closed (works as designed) » Active
StatusFileSize
new32.1 KB

This is still an active bug.

When you edit a term that has no parent, you cannot save it without the HS widget causing field validation to fail.

It appears that the problem is that a 'parent' value for a term with no parent is '0'. The HS widget doesn't appear to understand that '' should be pre-selected in this case.

In order to save the term, you need to re-select '' in the HS dialogue, click 'add', then click 'Save'.

brianV’s picture

Status: Active » Needs review
StatusFileSize
new603 bytes

Attached, please find a patch that should resolve this issue.

The following snippet is what is used to determine the default value for the parent field in hs_taxonomy_form_taxonomy_form_term_alter():

// Use Hierarchical Select for selecting the parent term(s).
$parent = isset($form['#term']['tid']) ? array_keys(taxonomy_get_parents($form['#term']['tid'])) : array(0);

However, if a term does not have parents, taxonomy_get_parents() returns an empty array. Because of this, so does the call to array_keys(). However, in order to make the '' term show by default, we need to specify array(0) as the default rather than an empty array.

The attached patch checks if $parent is an empty array, and uses the expected default value instead.

rajatgusain’s picture

StatusFileSize
new647 bytes

I was also working on the same bug.
And created a patch please find.

brianV’s picture

Same solution, but the one in #5 is likely a little cleaner.

jaymallison’s picture

Status: Needs review » Reviewed & tested by the community

Tested patch from post #5 on my install. Works great. This bug has been driving me crazy for the past couple days. Finally decided to check the queue, yay no more adding root each time I want to edit a term.

I'm marking this RTBC.

rajatgusain’s picture

thanks jaymallison..

pheraph’s picture

#5 fixes this problem for me, too. Thx rajatgusain.

schmidtk’s picture

#5 also worked for me. Thanks rajatgusain

amogiz’s picture

I applied the patch. It seems to work but …
Now it duplicates the node : when creating anew node, creating a new item in HS, duplicates the nodes !!!
I had to stop my website cause my clients were furious … Any help wound be really welcome.

jedihe’s picture

@amogiz: I think your problem is the one described at #1293166: Whole node form is saved instead of widget form, possible data loss

I also confirm that #5 corrected the problem for me.

Brandonian’s picture

StatusFileSize
new705 bytes

Rerolled patch #5. Seems to work for us.

serge86’s picture

Version: 7.x-3.x-dev » 7.x-3.0-alpha5

#5 fixed the problem for me. Thank you!

klaasvw’s picture

Version: 7.x-3.0-alpha5 » 7.x-3.x-dev

#13 Fixes the issue for me.

Also setting this back to dev.

wim leers’s picture

Component: Code - Content Taxonomy » Code - Taxonomy
Status: Reviewed & tested by the community » Fixed

Thanks! Committed #13, which is in fact #5, so credited @rajatgusain. Sorry for the massive delay in committing this very much needed bugfix.

Commit: http://drupalcode.org/project/hierarchical_select.git/commit/f6a6292

Rontero’s picture

StatusFileSize
new10.27 KB
new8.29 KB
new12.95 KB

#13 solves some of the problems. Here is one more.

My setup: drupal 7.12 (clean) with HS 7.x-3.x-dev (2012-Apr-19).

First screen shows my sample dictionary.
As you can see I have Shower term placed inside Bathroom term. Let's say I would like to change it. Now I want Shower term to appear as a child of Kitchen term. Well, I hit edit and scroll down to the relations section. Pic no. 2 shows the current setup. Since I don't want my term to appear inside Bathroom any more, I hit remove and that's the part when somethings goes wrong (as shown in last screen). I get this "Parents field is required." every time I select level with HS widget. It keeps showing until you select your final destination and hit add.

rajatgusain’s picture

Thanks Wim Leers !!!

martins.bertins’s picture

#17 In this case there is nothing wrong with HS.
The message is shown because the form is being validated on each ajax event and as you have removed the parent value the field is empty until you add a new value. The validation function is in core and has no conditions when it should be done and when shouldn't.

wim leers’s picture

#17: you have to select "<root>" :)

Status: Fixed » Closed (fixed)

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

charubachi’s picture

#5 patch works but there we are removing the condition for valid term tid.
while deleting a term it throws an error.