Hi,

I use taxonomy to tag up my nodes.
User don't need to to see the select field as it's all done within the code.

I managed to get it hidden on the node create form using a custom module but the node edit form does not hide the taxonomy select field. Is there something I am overlooking? My sample code is below. Thanks for your help.

function my_module_form_alter(&$form, $form_state, $form_id){

if ($form_id == 'my_form_id') {
$taxonomy = array(
			'#type' => 'hidden',
			'#value' => (!empty($form['taxonomy'][4]["#default_value"][0])) 
			? $form['taxonomy'][4]["#default_value"][0] : $my_deafult_value_variable,
		);
		$form['taxonomy'][4] = $taxonomy;
}

}

Comments

drclaw’s picture

Could you consider using css to hide the form element instead?

So your tagging is all done automatically? There is never a need to manually enter tags?

nevets’s picture

You could use taxonomy content and the field permission module. Use taxonomy content and instead of assigning the content type to the vocabulary add a taxonomy content field to the content type. With field permissions installed you will be able to specify the field requires editing permissions. If you do not assign any one those permission only user 1 will be able to see the field.

kungfuchris’s picture

Thanks for the response. Just before coming to check this post I came across another (http://drupal.org/node/49610) which pointed out a solution. The solution was to increase the weight of my custom module. I did that and the taxonomy filed is now a hidden field in both the add and edit form.

Thanks for your responses as it made me aware of those 2 other modules you mentioned. I am now going to have a look at those also.

thetoast’s picture

kungfuchris’s picture

Thanks for this link.