Hi all.
Is there any way to use cck fields in forms?
for example:
$form('item')=array(
'#type'=>'a ckk filed'
...
)

Comments

sunnydeveloper’s picture

Hi there,

I spent some time in recent months trying to answer that question for myself and, the short answer (and I would be thrilled to be wrong here) is 'no' you cannot define a CCK field in hook form. If you look at CCK fields they have a set of unique configuration for each, and are nto part of the form API:

http://api.drupal.org/api/file/developer/topics/forms_api_reference.html

You can use Content Type Export to copy a set of CCK field definitions, and import them either through Content Type Import, or programatically on Module install (which is what I did) based on some information I found here: http://drewish.com/node/118 using content_field_instance_create($field);

Again, I am hoping there is an easier way, but I haven't found it.

Hamid.D’s picture

Thank you.
I'm going to test it!