Hi,

Is there a way to add a "parent term" as with cck taxonomy?
I have a hierarchical taxonomy and i'd like to let a user choose only from one term and its children from the whole taxonomy.

Example:
- First
-- First Child
--- First Grandchild
- Second
-- Second Child

I'd like to exhibit to user only term 'First' and its children.

How can i do this?

Thanks

Comments

joachim’s picture

That's not something we're going to support in this module, because it goes beyond the stated purpose.

However, I reckon you could do that with hook_form_alter(), changing the list of taxonomy terms in the options array.

carvalhar’s picture

Hi Joachim,

Thanks for point me where to start. But could you provide more info?

I mean, user_term load terms at function user_terms_form_profile, right here:
$vocabulary = taxonomy_vocabulary_load($vid);

Isn't so? Shouldn't be there to edit the parent terms?

At content_taxonomy (where i saw the option to select a parent term and its children) there is this function:
$default_terms = taxonomy_get_children($parent, $field['vid']);

So, for my specif case i should do at user_terms_form_profile:
$vocabulary = taxonomy_get_children($parent, $vid);

I don't like to hack modules, but I don't know how can i do this using form_alter...which form should i change (i'm not using cck content type)? Is there a way to hook user_terms_form_profile?

Thanks,
Carlos

joachim’s picture

user_terms_form_profile() is called by hook_user(), which in turn is building up a form, so

dsm($form_id)

in a hook_form_alter() will tell you which form you need to alter :)