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.
@normawhite, @Spica, I was intrigued by the question and did some researchā¦
TLDR;
Copy /user/plugins/login/pages/login.md to user/pages/login/login.md
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:
...
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:
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
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.
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!
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ā¦
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!
@anon76427325 thank you for your explanation. Meanwhile I came up with the same solution as you did. But you where faster with responding
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
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.