Skip to content
Grav 2.0 is officially stable. Read the announcement →

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

Plugins

Login form - forgot button

Solved by Norma White View solution

Started by Norma White 7 years ago · 5 replies · 1122 views
7 years ago

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

7 years ago

@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:
    YAML
    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:
    TXT
    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:

    YAML
    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":

    TWIG
    {% if page.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!

  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:

    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...

  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
last edited 11/01/19 by pamtbaau
7 years ago

@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.

6 years ago Solution

@pamtbaau:
forgot_button: false

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

5 years ago

Hello,

very good work!

Just want to add, that in login version 3.4.1 the statement is missing a 's':

TWIG
{% 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.

Suggested topics

Topic Participants Replies Views Activity
Plugins · by Rene, 1 week ago
2 42 1 week ago
Plugins · by Xavier, 4 weeks ago
2 53 4 weeks ago
Plugins · by Luka Prinčič, 7 years ago
3 1179 1 month ago
Plugins · by Sebastian van de Meer, 1 month ago
1 47 1 month ago
Plugins · by PIERROT Alain, 2 months ago
3 71 2 months ago