Theme a CCK and content typeusing your custom theme Drupal 6

Spending several days for me to find out how to theming Input Form in CCK2 on Drupal 6, hope this can help you and save your time.

To theming CCK2 Input you just need:

  1. Edit template.php
  2. Create node-content_type-edit.tpl.php
  3. Clear Cache Data before view your result: Administer-Site Building-Performance: Clear Cache Data

EXAMPLE

Suppose your content-type is: "account_registration" and you theme is "bluemarine"

  1. Edit template.php, add this:
    <?php

    function bluemarine_theme($existing, $type, $theme, $path) {
      return array(
       
    'account_registration_node_form' => array(
           
    'arguments' => array('form' => NULL),
           
    'template' => 'node-account_registration-edit'
       
    )
      );
    }

    ?>
  2. Create node-account_registration-edit.tpl.php

    //To REMOVE Title field
    <?php unset($form['title']); ?>

    <fieldset class=" collapsible">
        <legend>Company Data</legend>
        <?php
         
    //NOTE: if you don't have Field Group then simply type:
          // print drupal_render($form['field_accreg_company_name']['0']['value']);
         
    print drupal_render($form['group_company']['field_company']['0']['value']);
          print
    drupal_render($form['group_company']['field_street']['0']['value']);
       
    ?>

    </fieldset> 
    <?php print drupal_render($form);  ?>
    <?php
    // print_r($form);   //Enable this to show all Array Variables of Form
    ?>

HOW TO ...........

  1. RENDER ONLY 1 FIELD
    <span style="color: rgb(0, 0, 0);"><span style="color: rgb(0, 0, 187);">&lt;?php </span><span style="color: rgb(0, 119, 0);">print </span><span style="color: rgb(0, 0, 187);">drupal_render</span><span style="color: rgb(0, 119, 0);">(</span><span style="color: rgb(0, 0, 187);">$form</span><span style="color: rgb(0, 119, 0);">[</span><span style="color: rgb(221, 0, 0);">'group_company'</span><span style="color: rgb(0, 119, 0);">][</span><span style="color: rgb(221, 0, 0);">'field_street'</span><span style="color: rgb(0, 119, 0);">][</span><span style="color: rgb(221, 0, 0);">'0'</span><span style="color: rgb(0, 119, 0);">][</span><span style="color: rgb(221, 0, 0);">'value'</span><span style="color: rgb(0, 119, 0);">]); </span><span style="color: rgb(0, 0, 187);">?&gt;</span></span>
  2. RENDER A GROUP OF FIELDS
    You don't need to render fields in group one by one, just enter this code to render all fields in a group:
    <?php print drupal_render($form['group_company']['field_street']['0']['value']); ?>
  3. RENDER A SELECT LIST
    Almost same like render a TEXTFIELD, but avoid ['0']['value'] at the end
    <span style="color: rgb(0, 0, 0);"><span style="color: rgb(0, 0, 187);">&lt;?php </span><span style="color: rgb(0, 119, 0);">print </span><span style="color: rgb(0, 0, 187);">drupal_render</span><span style="color: rgb(0, 119, 0);">(</span><span style="color: rgb(0, 0, 187);">$form</span><span style="color: rgb(0, 119, 0);">[</span><span style="color: rgb(221, 0, 0);">'group_company'</span><span style="color: rgb(0, 119, 0);">][</span><span style="color: rgb(221, 0, 0);">'field_region'</span><span style="color: rgb(0, 119, 0);">]); </span><span style="color: rgb(0, 0, 187);">?&gt;</span></span>
  4. REMOVE AN INPUT FIELD
    You may want to disable an input form, usually you need to remove TITLE as shown below:
    <span style="color: rgb(0, 0, 0);"><span style="color: rgb(0, 0, 187);">&lt;?php </span><span style="color: rgb(0, 119, 0);">unset(</span><span style="color: rgb(0, 0, 187);">$form</span><span style="color: rgb(0, 119, 0);">[</span><span style="color: rgb(221, 0, 0);">'title'</span><span style="color: rgb(0, 119, 0);">]); </span><span style="color: rgb(0, 0, 187);">?&gt;</span></span>
  5. HIDE AN INPUT FIELD (HIDE vs REMOVE!)
    You may still want to enable an input form but need to prevent it:
    <span style="color: rgb(0, 0, 0);"><span style="color: rgb(0, 0, 187);">&lt;?php $form</span><span style="color: rgb(0, 119, 0);">[</span><span style="color: rgb(221, 0, 0);">'title'</span><span style="color: rgb(0, 119, 0);">][</span><span style="color: rgb(221, 0, 0);">'#access'</span><span style="color: rgb(0, 119, 0);">] = </span><span style="color: rgb(0, 0, 187);">FALSE</span><span style="color: rgb(0, 119, 0);">; </span><span style="color: rgb(0, 0, 187);">?&gt;</span></span>
  6. SHOW ALL VARIABLES OF FORM
    You may want to know what variables available for you:
    <span style="color: rgb(0, 0, 0);"><span style="color: rgb(0, 0, 187);">&lt;?php print_r</span><span style="color: rgb(0, 119, 0);">(</span><span style="color: rgb(0, 0, 187);">$form</span><span style="color: rgb(0, 119, 0);">); </span><span style="color: rgb(0, 0, 187);">?&gt;</span></span>
  7. REORDER
    Use ['#weight'] to reorder
    $form['buttons']['#weight'] = -50; // buttons at the top
  8. PRINT BUTTONS
    <span style="color: rgb(0, 0, 0);"><span style="color: rgb(0, 0, 187);">&lt;?php </span><span style="color: rgb(0, 119, 0);">print </span><span style="color: rgb(0, 0, 187);">drupal_render</span><span style="color: rgb(0, 119, 0);">(</span><span style="color: rgb(0, 0, 187);">$form</span><span style="color: rgb(0, 119, 0);">[</span><span style="color: rgb(221, 0, 0);">'buttons'</span><span style="color: rgb(0, 119, 0);">]); </span><span style="color: rgb(0, 0, 187);">?&gt;</span></span>
  9. RENAMING BUTTON
    What is "Submit"? You may need to write it as "Save now!", don't you?
    $form['buttons']['submit']['#value'] = 'Save to Database';
  10. HIDE GROUP FIELD-SET
    $form['group_general']['#access'] = FALSE;
  11. HIDE BUTTON
    $form['buttons']['submit']['#access']= FALSE;
Ref: http://drupal.org/node/601646