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:
YAML
form:<-- Note the singular name "form"login:forgot_button:falseforms:<-- keep the rest the samelogin:...
In admin panel for Login plugin set field "Login path" to "/login". Or create file /user/config/plugins/login.yaml yourself and add:
TXT
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:
YAML
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":
TWIG
{%ifpage.header.forms.login.forgot_button??true%}
And added the following value to /user/plugins/login/pages/login.md:
YAML
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:
YAML
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!
@pamtbaau 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':
TWIG
{%ifpage.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.