I'm trying to customize user login form in (/user/login) page and I want to use a hook_form_alter function to add some awesome style and placeholder to each of user login form fields and remove or hide:
"Enter your admin username" and "Enter the password that accompanies your username" description expressions under each of theme.
I added something like below code to my ThemeName.theme:

function ThemeName_form_alter(&$form, $form_state, $form_id) {
  if ( $form['#form_id'] == 'user_login_form' ) {
    $form['actions']['submit']['#attributes']['class'][] = 'button glow button-primary expanded';
    $form['keys']['#attributes']['placeholder']['name'] = t('User Name');
    $form['keys']['#attributes']['placeholder']['password'] = t('Password');
  }
}

and I want to Achieve something like below image:
User Login Form

Comments

Jaypan’s picture

ok.

Mojtaba Reyhani’s picture

Is this means that I cant add a forum topic?

Jaypan’s picture

I don't understand the question - you already started this forum topic.

Jeff Burnz’s picture

He is reading is your signature - which is very confusing.

I answered his question on Drupal Answers.

Jaypan’s picture

He is reading is your signature

Ahh, I pointed out that the signatures don't have enough visual delineation from the posts months ago. Completely ignored. And I've seen the same mistake made between other users in the past too.

But as always, the people in charge don't care, because it's just the forums, and the forums don't matter to them.

Jeff Burnz’s picture

He was not confused because of the design, but rather the content, which you have full control over.

Jaypan’s picture

If the design clearly delineated the signature from the post, the confusion would not exist. It's only because someone who doesn't know the forum cannot clearly see the delineation, that the confusion exists.

VM’s picture

form_alters should go into custom modules. If you want to attempt at the theme layer see https://www.drupal.org/node/1949472

Jeff Burnz’s picture

Sorry VM but that is not correct and there is no "attempting" form alters in the theme layer when themes have access to form alters - zero difference to a module.

This is a design related change, not business logic - it very much should be in the theme.

Design decisions == theme level customisations. Drupal core supports hook_form_alter() in the themes for that very reason - because there are many design related changes one may wish to make to a form - alterations that belong firmly in the theme/view layer.

Jaypan’s picture

I agree with Jeff. Form logic goes in modules. Form output alterations belong in themes - unless the change should persist even with a change in themes, in which case it's better to put it into a module. My login form customizations are split between both. I change the help text in modules, and change ordering and adding/removing other elements in the theme.