Twig: Macros: Form: Use input options and primary submit button

main
Igor Scheller 5 years ago
parent 89742ecd55
commit 377b390c97

@ -1,18 +1,22 @@
{% macro input(name, label, type, required) %}
{% macro input(name, label, type, opt) %}
<div class="form-group">
{% if label %}
{% if label -%}
<label for="{{ name }}">{{ label }}</label>
{% endif %}
<input type="{{ type|default('text') }}" class="form-control" id="{{ name }}" name="{{ name }}"
{%- if required|default(false) %} required="required"{% endif -%}
{%- endif %}
<input type="{{ type|default('text') }}" class="form-control"
id="{{ name }}" name="{{ name }}"
value="{{ opt.value|default('') }}"
{%- if opt.required|default(false) %}
required="required"
{%- endif -%}
>
</div>
{% endmacro %}
{%- endmacro %}
{% macro hidden(name, value) %}
<input type="hidden" id="{{ name }}" name="{{ name }}" value="{{ value }}">
{% endmacro %}
{%- endmacro %}
{% macro submit(label) %}
<button type="submit" class="btn btn-default">{{ label|default(__('form.submit')) }}</button>
{% endmacro %}
<button type="submit" class="btn btn-primary">{{ label|default(__('form.submit')) }}</button>
{%- endmacro %}

@ -7,8 +7,8 @@
<form action="" enctype="multipart/form-data" method="post">
{{ csrf() }}
{{ f.input('password', __('Password'), 'password', true) }}
{{ f.input('password_confirmation', __('Confirm password'), 'password', true) }}
{{ f.input('password', __('Password'), 'password', {'required': true}) }}
{{ f.input('password_confirmation', __('Confirm password'), 'password', {'required': true}) }}
<div class="form-group">
{{ f.submit(__('Save')) }}

@ -19,7 +19,7 @@
{{ csrf() }}
{{ __('We will send you an e-mail with a password recovery link. Please use the email address you used for registration.') }}
{{ f.input('email', __('E-Mail'), 'email', true) }}
{{ f.input('email', __('E-Mail'), 'email', {'required': true}) }}
<div class="form-group">
{{ f.submit(__('Recover')) }}

Loading…
Cancel
Save