I'm trying to customize my user login page in my custom theme using the template file page--user--login.html.twig
, but am having issues accessing the different form elements. All aspects of the form are located in page.content
, but I'd like to edit the content that's being outputted.
For a simple example, the base theme has Username and Password stacked vertically, where I'd like to adjust this to use bootstrap so that they are stacked horizontally on large screen and vertically on mobile.
In Drupal 7, we had a form
element in the template file that allowed me to render certain form elements separately, like:
<div class="col-sm-12 col-lg-6">
<?php print drupal_render($form['name']); ?>
</div>
<div class="col-sm-12 col-lg-6">
<?php print drupal_render($form['pass']); ?>
</div>
Is there an equivalent for Drupal 8?
I attempted to create a template file for the form (form--user-login.html.twig
and form--user-login-form.html.twig
) to see if I could alter the form template itself instead of the page the form exists on, but didn't have any luck with that.
I'd prefer to override the current login theme instead of creating a whole new page and form and have to add all the necessary configurations so that a user lands on the correct login page, but have yet to find any way to do so, thanks in advance.