hello...

can anybody help me with the code to create custom user registration form similar to
http://zealind.com/?q=user/register&destination=user
with my own div wrappers and css class names ?...

Comments

Amruta_dani’s picture

you can add new fields to existing registration form
go to configuration->account settings->manage fields
then add new fields like First Name and select checkbox which says "Display on user registration form"
Save it
now logout or try to register to website in different browser, you can see the extra fields in registration.

Drupal developer

saleempbt5’s picture

thanks for your valuable reply ...

by using the above said method, we can only create additional fields in user registration forms.
but how can i give custom class name and div wrappers to the registration form fields..

is there any code to print the fields individually,
something like
$form['username'] ,$form['password'] and so on..

if so i can print those fields any where that i need (any templates.)

Amruta_dani’s picture

hm, I don't know much about theming as I know we can override existing registration form classes

Drupal developer

saleempbt5’s picture

well then we can learn together....
we can wait for someone else......

definitely there will be some techies , who have enough exposure in theming...

maheshg85’s picture

You can use Content profile module and create one content type. While creating that contnt type choose checkbox related to content profile and create You custom fields.Those fields will be used in your registration form. You can give any custom id or class to those fields using hook_form_alter .

saleempbt5’s picture

http://www.trellon.com/content/blog/theming-user-register-form-d6

it says some more programmatic approach than, the mixed...

saleempbt5’s picture

print drupal_render($form['timezone']);
print drupal_render($form['form_build_id']);
print drupal_render($form['form_id']);

or


 print '<div style="display:none">'. drupal_render($form).'</div>';// form id and extra fields if any

this also included in the user-register.tpl ..
otherwise the form wont work

also one can change the titles by using the code $form['mail']['#title']='Username/Email'; before rendering the elements..

blacklabel_tom’s picture

To add custom classes and div wrappers to fields, you will need to create your own module and use hook_form_alter to hook the registration form (http://api.drupal.org/api/drupal/modules%21system%21system.api.php/function/hook_form_alter/7)

To add classes you will need to find the field in the $form array and add to that elements ['#attributes']['class'] array:

$form['email']['#attributes']['class'][] = 'email-field';

To wrap a field in a div, you will need to set the ['#prefix'] and ['#suffix']:

$form['email']['#prefix'] = '<div class="email-wrapper">';
$form['email']['#suffix'] ='</div>';

Cheers

Tom

saleempbt5’s picture

please help me with some code or hint to add file field in the user registration form
i want to add a resume field in my user registration form of job portal