Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Hiboo
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ACIDES
Hiboo
Commits
34026e5e
Commit
34026e5e
authored
5 years ago
by
kaiyou
Browse files
Options
Downloads
Patches
Plain Diff
Improve the login form and add macros for forms
parent
14ea2fb6
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Pipeline
#243
passed
5 years ago
Stage: build
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
trurt/account/templates/account_login.html
+1
-6
1 addition, 6 deletions
trurt/account/templates/account_login.html
trurt/templates/macros.html
+47
-0
47 additions, 0 deletions
trurt/templates/macros.html
with
48 additions
and
6 deletions
trurt/account/templates/account_login.html
+
1
−
6
View file @
34026e5e
...
...
@@ -4,10 +4,5 @@
{% block subtitle %}{% endblock %}
{% block content %}
<form
method=
"POST"
action=
"{{ action }}"
>
{{ form.hidden_tag() }}
{{ form.username }}
{{ form.password }}
{{ form.submit }}
</form>
{{ macros.form(form) }}
{% endblock %}
This diff is collapsed.
Click to expand it.
trurt/templates/macros.html
+
47
−
0
View file @
34026e5e
...
...
@@ -34,3 +34,50 @@
</div>
</div>
{% endmacro %}
{% macro form_fields(fields, prepend='', append='', label=True) %}
{% set width = (12 / fields|length)|int %}
<div
class=
"form-group"
>
<div
class=
"row"
>
{% for field in fields %}
<div
class=
"col-lg-{{ width }} col-xs-12 {{ 'has-error' if field.errors else '' }}"
>
{{ form_individual_field(field, prepend=prepend, append=append, label=label, **kwargs) }}
</div>
{% endfor %}
</div>
</div>
{% endmacro %}
{% macro form_individual_field(field, prepend='', append='', label=True, class_="") %}
{% if field.type == "BooleanField" %}
{{ field(**kwargs) }}
<span>
</span>
{{ field.label if label else '' }}
{% else %}
{{ field.label if label else '' }}
{% if field.errors %}
{% for error in field.errors %}
<p
class=
"help-block inline"
>
{{ error }}
</p>
{% endfor %}
{% endif %}
{% if prepend or append %}
<div
class=
"input-group"
>
{% endif %}
{{ prepend|safe }}{{ field(class_="form-control " + class_, **kwargs) }}{{ append|safe }}
{% if prepend or append %}
</div>
{% endif %}
{% endif %}
{% endmacro %}
{% macro form_field(field) %}
{% if field.type == 'SubmitField' %}
{{ form_fields((field,), label=False, class="btn btn-default", **kwargs) }}
{% elif field.type not in ('HiddenField', 'CSRFTokenField') %}
{{ form_fields((field,), **kwargs) }}
{% endif %}
{% endmacro %}
{% macro form(form) %}
<form
class=
"form"
method=
"post"
role=
"form"
>
{{ form.hidden_tag() }}
{% for field in form %}
{{ form_field(field) }}
{% endfor %}
</form>
{% endmacro %}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment