1

I just want to do somthing without using module like profile2, so here is my requirement.

=> theme user registration form for e.g. I already have a beautiful user registration form as static html template which use bootstrap classes for css so how can I implement this html template in my drupal registration form..

=> In login form I want to remove tabs LIKE create new account and request new password and enstand of these tab I want to give like just before login button.

let me know if anything not clear.

1

1. theme user registration form

implement hook_theme:

function MYMODULE_theme()
{
  $return = array(
    'my_custom_registration_form' => array(
      'render element' => 'form',
      'template' => 'my_custom_registration_form'
    ),
  );

  return $return;
}

implement hook_form_alter:

function MYMODULE_form_alter(&$form, &$form_state, $form_id)
{
  //dpm($form_id);
  if ('user_register_form' == $form_id) {
    $form['#theme'] = 'my_custom_registration_form';
  }
}

create my_custom_registration_form.tpl.php file in MYMODULE directory, clear the cache, check if it works;

<?php dpm($form) ?>

copy html from your static file (just form part), put it into my_custom_registration_form.tpl.php, example (this will be different in your case):

<div class="col-md-4">
  <div class=""><?php print render($form['DESIRED_FIELD']) ?></div>
</div>
...

//render other fields (hidden fields), without them submit won't work
<?php print drupal_render_children($form) ?>

// or you can render them manually

// <?php print render($form['form_build_id']) ?>
// <?php print render($form['form_token']) ?>
// <?php print render($form['form_id']) ?>

2. In login form i want to remove tabs LIKE create new account and request new password - you can do it with CSS, or by removing $tabs variable from page template (you can create specific page template just for login page),

3. enstand of these tab i want to give like just before login button - with hook_form_alter fnction you can add other fields (manage theme) to the form

P>S: dpm() - is from Devel module

1
  • Too Cool and Easy, i don't have enough point to like. Thanks for your information. i will be use this soon. Oct 14 '14 at 10:31
0

For theming of your form :

  1. Impletement hook_form_alter
  2. Add the classes you want to any of form element like $form['element_name']['#attributes'] = array('class' => 'your_class');

To Hide Tabs :

  1. You can do this with css.
  2. or by creating a page.tpl.php for user register page.
0

You can use LoginToboggan module for your requirements. Optionally combine both the login and registration form on one page.

Elseif you wants to remove create new account tabs.

Go to admin/config/people/accounts and change " Who can register accounts? " to admin only.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.