preaction / Yancy

The Best Web Framework Deserves the Best Content Management System
http://preaction.me/yancy/
Other
54 stars 21 forks source link

form_for yancy.auth.password.login_form show empty form #100

Closed pavelsr closed 4 years ago

pavelsr commented 4 years ago

In Yancy::Plugin::Auth::Password#ROUTES manual said:

This plugin creates the following named routes. Use named routes with helpers like url_for, link_to, and form_for.

yancy.auth.password.login_form

Display the login form. See "TEMPLATES" below.

What is the correct usage of Yancy::Plugin::Form::form_for with yancy.auth.password.login_form named route ?

If I call

form_for('yancy.auth.password.login_form')

output is empty <form>...</form> :

<form action="/yancy/auth/password"></form>

There is no mention in Yancy::Plugin::Form::form_for how to use named route as argument, just $schema and %args

Also link_to('yancy.auth.password.logout') is working strange, output is <a href="/">yancy.auth.password.logout</a>

url_for helper works fine with yancy.auth.password.login named route as param.

preaction commented 4 years ago

To display the login form, you want to use the (undocumented, this is a bug) login_form helper:

%= $c->yancy->auth->login_form

All authentication modules install their helpers to the same place, so any auth module that has a login form will provide that helper. I'll improve the documentation in this area.

For the routes:

I'm going to add examples of how to use the route names and mention which ones should be used for which things (form submission, link generation, etc...).

Thanks for asking these questions! It really helps me improve the docs and also to know how folks are using these things :)