Set the allowed options of a selectlist CCK field? I have some CCK select list fields which I do not define allowed values for.

I need to set the options available using information available to me when the form is being loaded. 

I tried setting the values in the node-form.tpl file but I get:

"An illegal choice has been detected. Please contact the site administrator."

for each field I set the allowed values for in this way.

What's the proper way to do this?
check this resource http://drupal.org/node/726282 you will find a very useful description about CCK fields when form is loaded, and his relation with the function to alter forms, called hook_form_alter(). In few words, you must also use an after_build() function.