Programmatically add fields to content type I have created a content type in Drupal 7 using the following code.

function module_node_info() {
  return array(
    'module' =&gt; array(
      'name' =&gt; t('module'),
      'base' =&gt; 'module',
      'module' =&gt; 'module',
      'description' =&gt; t("You can add a content for module from here."),
    ),
  );
}


This seems to be working fine: I see the content type and I can add fields. When I create fields for this content type through code, the fields show up when I click on 'add content' but they are not showing in my content type. When I add nodes of that specific content type, the nodes are not showing and the fields are empty when I edit them.

I miss something, but I have no idea what that could be. I use the following code to create the fields.

function module_form($node, &amp;$form_state) {
  $form = array();

  $form['module_name'] = array(
    '#type' =&gt; 'textfield',
    '#title' =&gt; t('Enter the name of your module'),
    '#required' =&gt; TRUE, 
    '#description' =&gt; t('This name will be visible on the website'),
  );

  return $form;
}
The second piece of code creates a field in the Form API. This means that you do that when you create a custom form with several fields in it and then you have to handle its submission in your custom way. If this is what you want to do, fine. In this case you would need to add your custom form in your hook_menu().

Instead, from what I can understand with your question, you would like to add a field of the Field API to tour custom node type. For this matter you would need to use the field_create_field() and field_create_instance() functions. The excellent examples module provides very neat examples of how to accomplish that.