Custom User Login Template Error I am using Drupal 7 and I have added some code to my template.php file in my theme (which I found on a Drupal tutorial) so I can use a custom template for the user login form. The form works and it is using the custom template but it is generating these errors:

Notice: Undefined index: classes_array in template_process() (line 2527 of /includes/theme.inc).
Warning: implode(): Invalid arguments passed in template_process() (line 2527 of /includes/theme.inc).
Notice: Undefined index: attributes_array in template_process() (line 2533 of /includes/theme.inc).
Notice: Undefined index: title_attributes_array in template_process() (line 2534 of /includes/theme.inc).
Notice: Undefined index: content_attributes_array in template_process() (line 2535 of /includes/theme.inc).


The code I have in my template.php file is:

function cr_theme() {
  $items = array();

  $items['user_login'] = array(
    'render element' =&gt; 'form',
    'path' =&gt; drupal_get_path('theme', 'cr') . '/templates',
    'template' =&gt; 'user-login',
    'preprocess functions' =&gt; array(
       'cr_preprocess_user_login'
    ),
  );
  return $items;
}

function cr_preprocess_user_login(&amp;$vars) {
  $vars['forgot_link'] = l(t('Forgot password?'),'user/password');
}


and my user-login.tpl.php file contains:

&lt;div class="cr-user-login-form-wrapper"&gt;
  &lt;?php print drupal_render_children($form) ?&gt;
&lt;p style="margin-top:12px;"&gt;&lt;?php print render($forgot_link); ?&gt;&lt;/p&gt;
&lt;/div&gt;


I have been trying to find the cause of the errors which I think is probably something I have not added to my cr_theme() function but now need some help.
By playing around with the preprocess function I seem to have fixed the errors. I changed the preprocess function to:

function cr_preprocess_user_login(&amp;$vars) {
  $vars['content_attributes_array']['class'][] = 'content';
  $vars['title_attributes_array']['class'][] = 'content';
  $vars['attributes_array']['class'][] = 'content';
  $vars['classes_array'] = array('content');
  $vars['forgot_link'] = l(t('Forgot password?'),'user/password');
}


I just added in the undefined indexes that were coming up in the errors. I'm really not completely sure what I am doing but it does seem to be removing the errors so far.

It would be great if someone could comment how this is working.