Hi all,

I have a custom CCK field that I want to auto populate (don't want to use the autopopulate module as it's not maintained). Under my Content Type I'd like to enter a PHP code for the field. This code should return a single Taxonomy term of a Vocabulary, e.g. Vocabulary is Colour. Each node can only have single color - blue, red , green. I'd like to autopoulate my CCK field based on it's term.

I'm doing something wrong as I've been getting the error:

The default value PHP code returned an incorrect value.
Expected format:
return array(
0 => array('value' => value for value),
// You'll usually want to stop here. Provide more values
// if you want your 'default value' to be multi-valued:
1 => array('value' => value for value),
2 => ...
);
Returned value:

How do I get the Term value?

I would much appreciated your help as I left my book at work and really would like to crack on with this over the weekend.

Any help will be much appreciated,

Pav

Comments

Pav-2’s picture

Just a quick update for anyone who may need a similar solution. The easiest way to get a solution to this was for me not to use the PHP but instead do it with Rules - Event "After saving new content", Do "Populate created content's field".

Cheers anyway,

Pav

monge87’s picture

I wanted to fill a field with the name of the author of each content type, i wrote this

return array(
0 => array('author:user' => author:user);

But didn't work.., Could you tell me what should i write?