Programmatically create Fields in Drupal 7
I want to to add a cck field to a content type Programatically in drupal 7.
Any one who have some idea about this?
Drupal Answers is a question and answer site for Drupal developers and administrators. It only takes a minute to sign up.Sign up to join this community
The main functions of the Content Creation Kit (CCK) have migrated into core in Drupal 7. Now every object used by Drupal (users, nodes, even taxonomy terms) are "fieldable entities." What does this mean? Simply that you can add fields to most objects in Drupal out of the box, no CCK required!
If you're building a module that alters pre-existing node types, you'll need to check out the Entity API. I'm not too familiar with it myself, however, it doesn't seem that hard to programmatically add fields. As Bojan Zivanovic mentioned, there are many other answers dealing with this on Drupal StackExchange, here are a few for you to peruse:
If you're just adding fields to nodes for site building purposes, I'd just use the UI.
To do so...
You should then be presented with an interface to add new fields to your content type, much like you did with CCK in Drupal 6.