0
votes

I am attempting to create a node/content type in drupal, accordingly I have a .info, .install and .module file at minimum.

The module is created fine and I am able to enable/disable it from the module administration page, also, Drupal is able to recognize this module as a content type and it appears when I click 'Add content' in the Content menu.

Everything works fine, but it does not show the form elements, rather it starts directly at enter image description here

The form element code is listed below:

function newNode_form($node,&$form_state) 
{ 
 $type = node_get_types('type',$node); 

 $form['title']= array( 
    '#type' => 'textfield',  
    '#title' => check_plain($type->title_label),  
    '#default_value' => !empty($node->title) ? $node->title : '',  
    '#required' => TRUE,  
    '#weight' => -5, 
  ); 

  $form['field1'] = array( 
    '#type' => 'textfield',  
    '#title' => t('Custom field'),  
    '#default_value' => $node->field1,  
    '#maxlength' => 127, 
  ); 
  $form['selectbox'] = array( 
    '#type' => 'select',  
    '#title' => t('Select box'),  
    '#default_value' => $node->selectbox,  
    '#options' => array( 
      1 => 'Option A',  
      2 => 'Option B',  
      3 => 'Option C', 
    ),  
    '#description' => t('Choose an option.'), 
  ); 
return $form; 
}

Can anybody tell me what's wrong

P.S: Just F.Y.I: In my .install file, there exists only install and uninstall hook functions. I have yet to create DB tables, this content type is a walkthrough for me to create content type UI and not necessarily a full blown UI.

1

1 Answers

0
votes

Drupal's hook system uses lower cases and under scores to dynamically load module functions.

<module name>_<hook_name>

Try declaring your function like this:

function new_node_form($node, &$form_state) {
...