How is Default Value defined?

I have a Content Type of Nodeprofile with a Taxonomy Field LocationCountry so that the user selects the Country where he lives (the taxonomy is a limited list of countries).

I have another content type that the Taxonomy Field LocationCountry also uses. And I want that the Default value is the one that the user defined in his Nodeprofiles Taxonomy Field LocationCountry.

How am I able to make this?

CommentFileSizeAuthor
#2 taxonomyfield.gif13.68 KBarmand0

Comments

armand0’s picture

Nobody?
Cannot one make?
or does perhaps nobody know how?

armand0’s picture

StatusFileSize
new13.68 KB

For Taxonomy Field (active select) maybe:

 return array(array('value' => $myvar));  or
 return array(array('tid' => $myvar));   or
 return array('option' => array('value' => $myvar));  or
 return array(0 => array('value' => $myvar));

and anything works me. I hope somebody gives me an example of like it should be the syntax.
Thank you

jhedstrom’s picture

I solved this problem by returning an array of this form:

// for example, if I want tid 44 as the default:
return array(array(44 => 44));

This seems contrary to the description presented by cck:

array(0 => array('value' => value for value),
...
);

so I don't know if this is a bug in content taxonomy or not. I traced the problem all the way to the content_taxonomy_options_widget() function, where it calls array_keys to get the value, rather than looking for an array element "value"...

sittard’s picture

This worked for me:

global $user;
return array(
0 => array('value' => $user->mail)
);

jeff h’s picture

I can vouch for jhedstrom's post in #3... can we get the help text changed to reflect reality? :)

Vuds’s picture

Just to let documented (because this one was giving me pain to be found),

The PHP Code Default Value that works with CT Autocomplete field widget is

return array (array ($TID => taxonomy_get_term($TID)));

magnus’s picture

Status: Active » Closed (won't fix)

Cleanup of old issues. According to maintainer: "active development is only done for the 6.x branch! 5.x is not supported any more".
Open a new issue if problem still exist.