Programmatically creating a content type with file field in a custom module I'm writing a custom module, which I've done before, but this is the first time I've tried to create a content type with fields. I implemented hook_node_info and the Content Type is showing up in the list of Content types in the dropdown from admin_menu, however, when I browse to admin/structure/types it is not listed. 

I implemented hook_install and grabbed some code I found on another SO question. I have the code print out some debug info to my error log and it LOOKS like it all works, but when I browse to the Structure Content Type it doesn't show the field I added. 

Here are hooks:

function mymod_node_info() {
  return array(
    'mymod_content' =&gt; array(
      'name' =&gt; t('My Mod'),
      'base' =&gt; 'mymod_content',
      'description' =&gt; t('A Description'),
    )
  );
}

function mymod_install() {
    error_log('mymod_install');
    $types = node_type_get_types();

    if ( ! field_info_field('field_mymod_myfile') ) {
        $field = array(
            'field_name' =&gt; 'field_mymod_myfile',
            'type' =&gt; 'file',
        );
        $created_field = field_create_field($field);
        error_log('---- field_create_field -----');
        error_log(var_export($created_field, true));
    }

    $instance = array(
        'field_name' =&gt; 'field_mymod_myfile',
        'entity_type' =&gt; 'mymod_content',
        'bundle' =&gt; 'mymod_content',
        'required' =&gt; TRUE,
    );
    $created_instance = field_create_instance($instance);
    error_log('---- field_create_instance -----');
    error_log(var_export($created_instance, true));
}


I can see a table called field_data_field_mymod_myfile in the database, so I know the first part worked. However, the table is empty.

The error log shows the field_create_instance() method returned this:

array (
  'field_name' =&gt; 'field_mymod_myfile',
  'entity_type' =&gt; 'mymod_content',
  'bundle' =&gt; 'mymod_content',
  'required' =&gt; true,
  'field_id' =&gt; '5',
)


Why doesn't my field show up on this content type?
This isn't so much an answer as it is an expansion on the previous answer.

I found these two links very helpful in figuring out what the system needs for custom fields to be added to your custom module node type.

Best: http://www.sitepoint.com/creating-a-new-drupal-node-type/

Good additional info: http://public-action.org/content/drupal-7-field-api-drupal-7-adding-custom-content-type-custom-fields-field-api

The problem I had was that these (and every other example I can find online) are very specific examples without enough documentation to help me figure out a solution to my own usage case.

What helped was tenken's comment to the OP about using the Features module to get the arrays for the custom fields.

So I downloaded the Features module and enabled it: https://drupal.org/project/features

Then I created the fields on my content type, using the admin interface in Drupal like you normally would, that I wanted the module to create. Then I browsed to Structure > Features > Create feature and put in a bogus name (I used "test") for the feature and then over in the components area click on "Field Instances" and check the boxes for the custom fields. The fields are all named something like node-[your node type machine name]-[field name], so in my case since I wanted an image field it was node-novel_section-field_image.

After selecting the custom fields for my node type I then just clicked on "Download feature" and saved the .tar file to my desktop, opened it, opened the "test" folder then viewed the test.features.field_base.inc and test.features.field_instance.inc to get the arrays I needed for my fields.

Then I just used the structure outlined by that first link I posted and after that it worked perfectly. For me.

I could not find any documentation on the array structures needed for things like image fields and taxonomy reference fields and it seemed all other tutorials and help requests online are focused on specific things like text fields.

Hopefully anyone having the same trouble I was having will see this and be able to make their setup work using these examples and the Features module like I did.

Thanks to tenken for pointing out this functionality of the Features module, I'd never used it and didn't know it would do that.