3

Here is a custom user login form by Overriding the template. But can't understand how to print the destination/action path on the form. here is my code:

block--user--login.tpl.php

<form accept-charset="UTF-8" id="user-login-form" method="post" action="/node?destination=node">
  <div class="custom-form">
    <div class="form-item form-type-textfield form-item-name">
  <label for="edit-name">Username <span title="This field is required." class="form-    required">*</span></label>
  <input type="text" class="form-text required" maxlength="60" size="15" value=""     name="name" id="edit-name">
</div>

    <div class="form-item form-type-password form-item-pass">
  <label for="edit-pass">Password <span title="This field is required." class="form-required">*</span></label>
  <input type="password" class="form-text required" maxlength="60" size="15" name="pass" id="edit-pass">
</div>

<div id="edit-actions" class="form-actions form-wrapper">
  <input type="submit" class="form-submit" value="Log in" name="op" id="edit-submit">
</div>

<div class="item-list">
  <ul>
    <li class="first"><a title="Create a new user account." href="/user/register">Create new account</a></li>
        <li class="last"><a title="Request new password via e-mail."     href="/user/password">Request new password</a></li>
  </ul>
</div>

<input type="hidden" value="<?php print $elements['form_build_id']['#value']; ?> "     name="form_build_id">
    <input type="hidden" value="user_login_block" name="form_id">
  </div>
</form>

Here we are using a default path like action="/node?destination=node" its really a bad idea..
So i want to print the action path programmatically.. Any idea?
This maybe an idea: <?php print $elements['actions']['#the_path']; ?>

1 Answer 1

1

The action is stored in the form's #action property, so assuming your form is represented by the $elements variable in the template, something like this should do it:

<form accept-charset="UTF-8" id="user-login-form" method="post" action="<?php echo $elements['#action']; ?>">
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.