1

I want to alter the login form to display only the @username and @password inputs.

  1. Is it mandatory to write another module to overwrite the user module? Can it be done from my PHP block by using these 2 variables? If yes, how can I find the name of the variables?
  2. What is the Drupal recommended way for doing this?
0

There are two ways to display only some fields:

  1. Get the original form, and remove unneeded fields. This can be done 2 ways, in hook_form_alter() or by calling drupal_get_form() and working on outputted array. This way is risky - save handler might be unable to save if some fields it expects are missing.
  2. Create your own form, with your own inputs, validators and save handlers. Copy strings from form you are copying to keep using any translations already available. This is safer, but requires a bit more work.

In theory you can handle form in a block with php filter. I would not recommend it. It's way more manageable to keep code in files. And if you have APC, it's also way faster. Thus, modules are the way to go.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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