Theme a CCK input form for CCK2
Last modified: November 24, 2009 - 16:54
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:
-
Edit template.php
Create node-content_type-edit.tpl.php
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"
-
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'
)
);
}
?>//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 ...........
-
RENDER ONLY 1 FIELD
<?php print drupal_render($form['group_company']['field_street']['0']['value']); ?>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']); ?>Almost same like render a TEXTFIELD, but avoid ['0']['value'] at the end
<?php print drupal_render($form['group_company']['field_region']); ?>You may want to disable an input form, usually you need to remove TITLE as shown below:
<?php unset($form['title']); ?>You may still want to enable an input form but need to prevent it:
<?php $form['title']['#access'] = FALSE; ?>You may want to know what variables available for you:
<?php print_r($form); ?>Use ['#weight'] to reorder
$form['buttons']['#weight'] = -50; // buttons at the top<?php print drupal_render($form['buttons']); ?>What is "Submit"? You may need to write it as "Save now!", don't you?
$form['buttons']['submit']['#value'] = 'Save to Database';$form['group_general']['#access'] = FALSE;$form['buttons']['submit']['#access']= FALSE;