PHPJavascript

Web Development Guide – My Personal Library of Tutorials and Scripts

Drupal Theme Form CCK User Register

August4

To theme drupal forms using cck fields do the following:

Insert theme hook function in the template.php file: (dmcdubai is my theme name, replace it with yours)

function dmcdubai_theme($existing, $type, $theme, $path) {
 return array(
 'profile_node_form' => array(
 'arguments' => array('form' => NULL),
 'template' => 'node-profile-edit'
 ),
 'user_register' => array(
 'arguments' => array('form' => NULL),
 'template' => 'node-profile-edit'
 )
 );
}

Create node-profile-edit.tpl.php file in your theme folder. Enter relevant fields in the order you need on the form

Eg

<?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']);
?>

visit http://drupal.org/node/601646 for more details on how to display or order the fields of a form.

Go back to the code we had inserted in the template.php file. The profile_node_form and user_register are the ids of the form where the theming done in node-profile-edit.php will be applicable. So if you add user_register in the theming will also be applicable in the “Create New Account” scenario.

To find out the id of your form, view source and find name=”form_id” and use the value of that field.

posted under Drupal
One Comment to

“Drupal Theme Form CCK User Register”

  1. On August 4th, 2011 at 7:45 am » Drupal Form Theme CCK PHPJavascript Web Development Guide – My Personal Library of Tutorials and Scripts Says:

    [...] know more on the subject visit http://www.phpjavascript.com/drupal-theme-form-cck-user-register/ posted under [...]

Email will not be published

Website example

Your Comment:

 

13,816 spam comments
blocked by
Akismet