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.
1 Answer
@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 -
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; }
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); }
The line
dsm($form)
is just for your help. Do not forget to remove/comment it once you are done with the changes.NOTE You will be required to clear you sites theme registry cache to see the changes take affect.
Hope this helps :-)