Personalizar el formulario de login en Drupal 6

Procedimiento.

Editar el archivo template.php y agregar la siguiente función (el nombre es libre).

function phptemplate_generarFormularioLogin()
{
   $form_id = 'user_login';
   $form = array();

   $form['name'] = array(
      '#type' => 'textfield',
      '#maxlength' => USERNAME_MAX_LENGTH,
      '#required' => TRUE,
      '#attributes' => array('tabindex' => '1',
      'class' => 'registro'),
   );

   $form['pass'] = array(
      '#type' => 'password',
      '#required' => TRUE,
      '#attributes' => array('tabindex' => '2',
      'class' => 'registro'),
   );

   $form['submit'] = array(
      '#type' => 'submit',
      '#value' => t('Log in'),
      '#weight' => 2,
      '#attributes' => array('tabindex' => '3')
   );

   $form['#validate'] = user_login_default_validators();
   $form['#build_id'] = sprintf('form-%s', md5(uniqid(mt_rand(), TRUE)));

   $form_state = array();

   drupal_prepare_form($form_id, $form, $form_state);
   drupal_process_form($form_id, $form, $form_state);

   $out = new stdClass;
   $out->form_start = sprintf("<form method='post' accept-charset='UTF-8' action='%s'>",
                             url('user/login'));
   $out->form_end = "</form>";

   $out->name = drupal_render($form['name']);
   $out->pass = drupal_render($form['pass']);
   $out->submit = drupal_render($form['form_id']) .

   drupal_render($form['form_build_id']) .
   drupal_render($form['submit']);

   return $out;
}

Insertar en el lugar deseado de page.tpl.php el siguiente fragmento de código o su correspondiente personalización.

<?php $login_form = phptemplate_generarFormularioLogin(); ?>
<?php print $login_form -> form_start; ?>
    Usuario &nbsp; <?php print $login_form->name; ?> &nbsp;&nbsp;&nbsp;
    Contraseña &nbsp; <?php print $login_form->pass; ?>&nbsp;&nbsp;
    <?php print $login_form->submit; ?>
<?php print $login_form->form_end; ?>

Enlaces.

One thought on “Personalizar el formulario de login en Drupal 6”

Leave a Reply

Your email address will not be published. Required fields are marked *