mirror of https://github.com/rwf2/Rocket.git
Fix off-by-one, improve style in forms example.
This commit is contained in:
parent
c6192c1c0b
commit
55b7d4574a
|
@ -13,16 +13,25 @@
|
|||
margin: 0 auto;
|
||||
padding: 20px 10px;
|
||||
}
|
||||
|
||||
h1 {
|
||||
margin: 10px 0;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<h1>Form Example</h1>
|
||||
|
||||
{% if errors | length > 1 %}
|
||||
<small class="text-error" style="margin-top: -20px">
|
||||
{{ errors | length }} field(s) have errors
|
||||
</small>
|
||||
{% if errors | length > 0 %}
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<small class="text-error">
|
||||
error: {{ errors | length }} field{{ errors | length | pluralize }}
|
||||
failed to validate
|
||||
</small>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<form action="/" method="post" enctype="multipart/form-data">
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
{%- if name in values -%}
|
||||
{{- values | get(key=name) | first -}}
|
||||
{%- endif -%}
|
||||
{% endmacro %}
|
||||
{% endmacro value_for %}
|
||||
|
||||
{% macro errors_for(name) %}
|
||||
{%- if name in errors -%}
|
||||
|
@ -11,7 +11,7 @@
|
|||
<p class="text-error is-marginless">{{ error.msg }}</p>
|
||||
{% endfor %}
|
||||
{%- endif -%}
|
||||
{% endmacro %}
|
||||
{% endmacro errors_for %}
|
||||
|
||||
{% macro input(type, label, name, value="") %}
|
||||
<label for="{{ name }}">{{ label }}</label>
|
||||
|
@ -37,7 +37,7 @@
|
|||
>
|
||||
{{ label }}
|
||||
</label>
|
||||
{% endmacro input %}
|
||||
{% endmacro checkbox %}
|
||||
|
||||
{% macro textarea(label, name, placeholder="", max=250) %}
|
||||
<label for="{{ name }}">{{ label }}</label>
|
||||
|
@ -49,7 +49,7 @@
|
|||
</textarea>
|
||||
|
||||
{{ self::errors_for(name=name) }}
|
||||
{% endmacro input %}
|
||||
{% endmacro textarea %}
|
||||
|
||||
{% macro select(label, name, options) %}
|
||||
<label for="{{ name }}">{{ label }}</label>
|
||||
|
@ -60,4 +60,4 @@
|
|||
>{{ value }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
{% endmacro input %}
|
||||
{% endmacro select %}
|
||||
|
|
Loading…
Reference in New Issue