0

I have a modal form for user login. I want to rearrange the links. I enabled captcha for user login form. Now i want to display 'Create New Account' and 'Forget Password' links to be displayed below the 'Login' submit button. I need help on how to do this. Thanks in advance.

2
  • Which version of Drupal are you using?
    – acouch
    Commented Mar 13, 2012 at 7:40
  • i am using drupal 7 with ctools and modal forms to display the popup.
    – jags
    Commented Mar 13, 2012 at 7:43

1 Answer 1

4

@jags: Always make sure to mention what version of Drupal you are working on as the answers could be sightly different for different Drupal versions.

You essentially have to change the HTML that gets generated to render the form. Such 'theme override' can be done at multiple places. In your case a good place to do so is the theme layer. Assuming that you are on version 7, the below is what you will need to do -

  1. In your theme's directory edit the file called 'template.php' to register a new theme function

    /**
     * Implementation of HOOK_theme().
     */
    function THEME_NAME_theme(&$existing, $type, $theme, $path) {
      $hooks = array();
      // Add your theme hooks like this:
      $hooks['FORM_ID_FOR_THE_FORM_YOU_WISH_TO_EDIT'] = array(
          'arguments' => array('form' => NULL),
        );
      return $hooks;
    }
    
  2. Now create the new theme function and make changes to the '#weight' property of the desired elements to change the order in which they appear in the form

    function cio_st_FORM_ID_FOR_THE_FORM_YOU_WISH_TO_EDIT($form) {
      dsm($form); // This line will show you the content of $form and help you know which attribute you would like to edit. You will be able to use this function only if the devel module is turned on. 
    
      // Make the changes in the '#weight' attribute of the desired elements to change the order in which they get rendered.
    
      return drupal_render($form);
    }
    
  3. The line dsm($form) is just for your help. Do not forget to remove/comment it once you are done with the changes.

  4. NOTE You will be required to clear you sites theme registry cache to see the changes take affect.

Hope this helps :-)

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.