Skip to content
This repository was archived by the owner on Jul 31, 2020. It is now read-only.

Add password type to simple widget #8

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions src/Resources/views/Form/fields.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@

{%- block form_widget_simple -%}
{%- set type = type|default('text') -%}

{%- set password = type == 'password' -%}

{% if label is empty -%}
{%- if label_format is not empty -%}
{% set label = label_format|replace({
Expand All @@ -35,12 +36,12 @@
{%- if type is not same as('hidden') -%}

{% set type = textarea is defined ? 'textarea' : 'text-field' %}
<v-{{ type }} type="{{ type }}" label="{{ label }}" value="{{ value }}" {{ block('widget_attributes') }}
<v-{{ type }} type="{{ password ? 'password' : type }}" label="{{ label }}" value="{{ value }}" {{ block('widget_attributes') }}
{%- if errors|length > 0 %} error :error-messages="[{%- for error in errors -%}'{{ error.message|e('html_attr') }}'{%- endfor -%}]" {%- endif -%}
{% if required %}class="required"{% endif %}
></v-{{ type }}>
{%- else -%}
<input type="{{ type }}" {{ block('widget_attributes') }} {% if value is not empty %}value="{{ value }}" {% endif %}/>
<input type="{{ password ? 'password' : type }}" {{ block('widget_attributes') }} {% if value is not empty %}value="{{ value }}" {% endif %}/>
{%- endif -%}
{%- endblock form_widget_simple -%}

Expand Down Expand Up @@ -207,4 +208,4 @@
})|raw -}}
</div>
{%- endif -%}
{%- endblock month_widget -%}
{%- endblock month_widget -%}