I am new to Drupal and wondering how to edit the look and feel of the registration page form? For what it's worth, I'm using the Bootstrap theme. I'd usually do this via CSS; however, with Drupal this is somewhat tricky. The problem is the form fields are expanding to fill their container, and, as you can imagine, it looks pretty ridiculous having a username field filling 3/4 of the screen. Looking at the elements class shows no clues as it is not a standard Bootstrap class (must be Drupal generated I imagine). I have edited the basic page content type in an attempt to make it work - but as I have learnt: the registration page is not styled from basic page. Any help would be great, thanks!


Take a look at drupal api documentation. Customizing forms is quite easy. https://api.drupal.org/api/drupal/modules%21system%21system.api.php/function/hook_form_FORM_ID_alter/7

Just hook into that user_registration_form and for example add into class index bootstrap classes col col-lg-*. Or you can add #prefix and #suffix to wrap things into columns etc. And install Devel module to examine form's structure.

I'm not sure if it possible to use page--user--register.tpl.php to modify layout. Possibly you could create that and add col col-lg-offset-* col-lg-* to whatever element is the container for page[content] variable.

  • Thanks for the help. I've used a hook as you mentioned and the #prefix and #suffix attributes (?). Strangely, what I'm creating before and after the form is actually created around the parent of the form. This is a bit strange but perhaps this is normal behaviour for Drupal. The forms parent is a section with a different ID. Any ideas?
    – monster
    Oct 26 '15 at 10:15
  • Bootstrap theme has a section element as wrapper. you can see it from page.tpl.php. Classes for it are printed with php on the same line. And you can also try adding prefix and suffix to form elements instead for whole form e.g. $form['username']['#prefix'] or similar. Oct 26 '15 at 17:20

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.