Login form - forgot button

I would like to disable the forgot button on the login form.

I found a promising place in login-form.html.twig
There is a test of {% if page.header.form.login.forgot_button ?? true %}
which would remove it.
But I am clueless as to where and how I could change that variable to false?

I have also failed to find out where in the admin that button comes from.

Any ideas?

Thanks

Norma

Found any solution on that?

@normawhite, @Spica, I was intrigued by the question and did some researchā€¦

TLDR;

  1. Copy /user/plugins/login/pages/login.md to user/pages/login/login.md
  2. Add to your login.md a new ā€œformā€ section:
    form:          <-- Note the singular name "form"
       login:
          forgot_button: false
    forms:         <-- keep the rest the same
       login:
       ...
    
  3. In admin panel for Login plugin set field ā€œLogin pathā€ to ā€œ/loginā€. Or create file /user/config/plugins/login.yaml yourself and add:
    route: /login
    

NB. I have posted a feature request for a config setting.

Long read:

If you are interested, here is the research:

  1. I started of with the OPs reference to {% if page.header.form.login.forgot_button ?? true %} which points to the frontmatter in the current page. So I added:

    form:
       login:
          forgot_button: false
    

    However that didnā€™t work

  2. I switched on the debugger and added {{ dump(page) }} to the template /user/plugins/login/templates/partials/login-form.html.twig to inspect the values of the frontmatter. There was no entry for page.header.form.login.forgot_button in the dump.

    But the dump did show me that the page is not the ā€œcurrentā€ page which invoked the login, but instead was /user/plugins/login/pages/login.md.

  3. That page contains frontmatter forms.login, which containing all settings for the login form. Note however it contains ā€œforms.loginā€ and not ā€œform.loginā€. This means the template is probably referencing the wrong frontmatter field.

    I corrected the template login-form.html.twig to use ā€œformsā€:

    {% if page.header.forms.login.forgot_button ?? true %}
    

    And added the following value to /user/plugins/login/pages/login.md:

    forms:
       login:
          forgot_button: false
          ...
    

    That worked!

  4. Editing the plugin itself is never a good idea, so I copied /user/plugins/login/pages/login.md into my own /user/pages/login/ folder and added:

    forms:
       login:
          forgot_button: false
          ...
    

    Refreshed the page, but no luckā€¦ ā€œForgotā€ button still there.

    Why? According the debugger, my own login page wasnā€™t being calledā€¦

  5. In the admin panel for plugin ā€œLoginā€ I found a field called ā€œLogin pathā€. I set that to ā€œ/loginā€ to point to my own login page.

    My own login page is now being called. Andā€¦ the ā€œForgotā€ button is gone!

1 Like

@pamtbaau thank you for your explanation. Meanwhile I came up with the same solution as you did. But you where faster with responding :slight_smile:
It was a hard time to figure out, as it was not self explaining and only try and error brought me there.
What I am still missing, is the possiblility to configure different login forms, e.g. one with and one without forgott-button for different use cases reflecting the page you originaly wanted to browse. But there is only one route for the login page and therefore only one global login form.

Many thanks that works, though it is far too deep for me to understand and I would never have found it.
Sorry, it took a pandemic to give me time to react to this and again thank you both so much. Norma

Hello,

very good work!

Just want to add, that in login version 3.4.1 the statement is missing a ā€˜sā€™:

{% if page.header.form.login.forgot_button ?? true %}

so that variable is ā€˜nullā€™ an the expression then is evaluated true. I changed this to ā€˜formsā€™ in my login-form.html.twig , then it works as discribed.