Hi!

In Drumepal 6, theming stuff was supposed to be easier, but I'm not really feeling it. Doing my first D6 theme now and Im stuck on the login form.

I found this great article on lullabot: http://www.lullabot.com/articles/modifying-forms-5-and-6

And I've tried to modify their template.php functions for use with my theme, but the following code does not touch the login form:

function mytheme_theme() {
  return array(
    // The form ID.
    'user_login_form' => array(
      // Forms always take the form argument.
      'arguments' => array('form' => NULL),
    ),
  );
}
function mytheme_user_login_form($form) {
  $output = '';
  // Print out the $form array to see all the elements we are working with.
  $output .= 'BLABLABLBLAAAA';
  $output .= print_r($form);
  // Once I know which part of the array I'm after we can change it.

  // You can use the normal Form API structure to change things, like so:
  // Change the Username field title to Login ID.
  

  // Make sure you call a drupal_render() on the entire $form to make sure you
  // still output all of the elements (particularly hidden ones needed
  // for the form to function properly.)
  $output .= drupal_render($form);
  return $output;
}

And as far as I can see, user-login is also not one of the new default templates in D6, any help would be greatly appreciated!

Comments

somes’s picture

that article might be a bit out of date (maybe)
try here
http://www.drupaldojo.com/lesson/fine-tuning-the-ui-by-theming-forms-in-...

I've tried theming the login form but haven't had any success - from what i remember I think i was calling an incorrect id for the form, I'd be interested if you have a solution Ive posted on this on the forums here
http://drupal.org/node/240124

jurriaanroelofs’s picture

Hi, I dont think the lullabot article is out of date, I tried their example with the user edit form and it worked just fine.
I'll download the screencast for later, thanks ;)

-------------------------------
peach from All Drupal Themes

-------------------------------
http://www.sooperthemes.com/#-Drupal-Themes

somes’s picture

I should have extend theres a lot more preprocessing capabilities in D6 a lot more control

gpista’s picture

I've found the source of the problem. After looking at the source of the user.module, I've found that the id of the user login form is not it's html id (user_login_form), but user_login_block.
So it works this way:

function mytheme_theme() {
  return array(
    // The form ID.
    'user_login_block' => array(
      // Forms always take the form argument.
      'arguments' => array('form' => NULL),
    ),
  );
}
function mytheme_user_login_block($form) {
  $output = '';
  // Print out the $form array to see all the elements we are working with.
  $output .= 'BLABLABLBLAAAA';
  $output .= print_r($form);
  // Once I know which part of the array I'm after we can change it.

  // You can use the normal Form API structure to change things, like so:
  // Change the Username field title to Login ID.
 

  // Make sure you call a drupal_render() on the entire $form to make sure you
  // still output all of the elements (particularly hidden ones needed
  // for the form to function properly.)
  $output .= drupal_render($form);
  return $output;
}

Lesson learned: always search for drupal_get_form in the source of the module because naming of the form ids are not always consistent.

somes’s picture

Good find Istvan
That fixes that problem thanks for the tip

rickhocutt’s picture

I was going nuts trying to figure out why "user_login_form" wasn't working until I found this post. I never would have thought about using "user_login_block".

Thanks!

drupallearner-2’s picture

Can u please let me know where to add this above code In order to modify the login form inputs

somes’s picture

in your theme template.php file
also make sure that you clear the theme cache

place

'drupal_rebuild_theme_registry();'

at the beginning of you template.php file

for a production site you dont need it ........

Shawn_S’s picture

I found a very useful post that helped me solve this at:

http://drupal.org/node/478328