Hi there!
I´m creating a custom log-in block, and want to put inside there the Remember me checkbox.
Anyone could help me on how to do that? I mean, this is what I´ve got, but ain´t working:

        <input type="checkbox" name="remember_me" id="remember" value="1"   tabindex="3"  />
        <label for="remember">Recordarme</label>

Any ideas?
Thanks!!!
Rosamunda

Comments

frankspin’s picture

Subscribing

Rosamunda’s picture

anyone?

nickl’s picture

Category: task » support
Status: Active » Postponed (maintainer needs more info)

Exactly how is this implemented? The custom form will still need to submit to user login to authenticate the user. Can you authenticate with your supplied username and password fields?

Please provide more information.

nickl’s picture

Status: Postponed (maintainer needs more info) » Closed (cannot reproduce)

No response for 6 weeks, closing.

Feel free to reopen the issue if more information becomes available.

atin81’s picture

Ok, I'm going to reopen this. I'm trying to create a custom login block using theme function and this user-login-block.tpl.php file

<h2>User <span>Login</span></h2>
<form action="<?php echo $_SERVER['REDIRECT_URL']; ?>?destination=<?php echo urlencode($_SERVER['REDIRECT_URL']); ?>"  accept-charset="UTF-8" method="post" id="user-login-form">
  <div>
    <div class="item-list">
      <ul>
        <li class="first">
          <a href="user/register" title="Create Account.">Get Your CGL Account</a>
        </li>
        <li class="last">
          <a href="user/password" class="automodal" title="Request new password via e-mail.">Password?</a>
        </li>
      </ul>
    </div>
    <div class="form-item" id="edit-name-wrapper">
      <label for="edit-name">Username: <span class="form-required" title="This field is required.">*</span></label>
      <input type="text" maxlength="60" name="name" id="edit-name" size="15" value="" class="form-text required" />
    </div>
    <div class="form-item" id="edit-pass-wrapper">
      <label for="edit-pass">Password: <span class="form-required" title="This field is required.">*</span></label>
      <input type="password" name="pass" id="edit-pass"  maxlength="60"  size="15"  class="form-text required" />
    </div>
    <input type="submit" name="op" id="edit-submit" value="Log in"  class="form-submit" />
    <input type="hidden" name="form_build_id" id="<?php form_clean_id('edit-'. drupal_get_token()  .'-form-token') ?>" value="<?php drupal_get_token() ?>"  />
    <input type="hidden" name="form_id" id="edit-user-login-block" value="user_login_block"  />
  </div>
</form>

Now the question is, how do I make "Remember me" checkbox render?

nickl’s picture

Status: Closed (cannot reproduce) » Postponed (maintainer needs more info)

Nope that won't work besides, I am sure you are breaking a fare amount of rules here but if it works then I guess go for it.

We are using hook_form_alter to add the checkbox so you will probably need to call drupal_get_form('user_login_block'); somewhere.

Have you tried just including the remember_me checkbox html as you did with name and password?

Please post the result if you got it to work.

atin81’s picture

Sorry for late respond, just being bussy with other part of the project and until today I don't have look into this.

As you sugested, adding this code make the trick:

<div id="edit-remember-me-wrapper" class="form-item">
  <label for="edit-remember-me" class="option">
  <input type="checkbox" class="form-checkbox" tabindex="3" checked="checked" value="1" id="edit-remember-me" name="remember_me"> Remember me</label>
</div>

Now my question, you have told me that I have break many rules with this custom implementation, but I tried lot of ways to customize the userlogin block and this was the only one to works for me, could you please indicate me what will be the right way to make this?

Thanks in advance.

nickl’s picture

Status: Postponed (maintainer needs more info) » Fixed

Hey if it works for you I say go for it =)

My theming foo is not all that up to speed but if you call drupal_get_form('user_login_block'); it will return the rendered html after allowing all the other modules to do their hook_form_alter implementations.
If you want to be able to specify a custom theme to be used for a specific form to be used when drupal call drupal_get_form, rather make a hook_form_alter implementation and set the $form['#theme'] to point to your template and the new data will be passed to it when drupal_render_form calls drupal_render to invoke the theme hook you specified.

This way you don't bypass any of the normal drupal functionality and you still allow the contrib modules to do the work they expected to do. This is what I meant by breaking the rules, as modules rely on being called and lots of things can go wrong when they don't. Like the Remember me checkbox vanishing from your login form.

Hey lookie here Login form theming now what have you.

Don't hurt the kittens =) hope this helps.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.