[development] programatically adding a CCK field to a content type.
drewish at katherinehouse.com
Mon Sep 21 18:16:37 UTC 2009
On Mon, Sep 21, 2009 at 6:51 AM, nitin gupta <nitingupta.iitg at gmail.com> wrote:
> I wanted to add an imagefield to a content type, using the function
> content_field_instance_create(). I wrote this piece of code.
> $field['field_name'] = 'myfield';
> $field['type_name'] = 'story';
> $field['type'] = 'filefield';
> $field['widget_type'] = 'imagefield_widget';
> module_load_include('inc', 'content', 'includes/content.crud');
> This works perfectly fine with me, and an imagefield gets added to the
> content type. are there any pitfalls in this i should take care of? or is
> there any better way to do such a thing?
That's basically the approach I've been using for over a year:
The only complications I ran into with this approach was when you
added fields in hook_install() and need to ensure field modules are
More information about the development