Working with forms
If we look at the structure of the form for new_user
and edit_user
, we can see that both forms are almost the same, with just a few differences. For example, the forms' action
endpoints are different, as there are two extra fields for edit_user
: _METHOD
and old_password
. To simplify, we can make one template to be used by both functions. Let's look at the steps:
- Create a template called
src/views/users/form.html.tera
, and insert the following lines:{% extends "template" %} {% block body %} <form accept-charset="UTF-8" action="{{ form_url }}" autocomplete="off" method="POST"> <fieldset> </fieldset> </form> {% endblock %}
- Next, let's add the title to the form by adding a
legend
tag. Put this inside thefieldset
tag:<legend>{{ legend }}</legend>
- Under the
legend
tag,...