Add placeholder to indicate required file types in forms

This commit is contained in:
Patrick Jentsch 2020-04-23 12:39:59 +02:00
parent bbcf5c5312
commit 154631dcb4
5 changed files with 11 additions and 10 deletions

View File

@ -24,7 +24,7 @@
{{ M.render_field(add_corpus_file_form.publishing_year, material_icon='access_time') }}
</div>
<div class="col s12">
{{ M.render_field(add_corpus_file_form.file, accept='.vrt') }}
{{ M.render_field(add_corpus_file_form.file, accept='.vrt', placeholder='Choose your .vrt file') }}
</div>
</div>
</div>

View File

@ -1,5 +1,5 @@
{% macro render_field(field) %}
{% if field.flags.required %}
{% if field.flags.required and field.type not in ['FileField', 'MultipleFileField'] %}
{% if 'class_' in kwargs and 'validate' not in kwargs['class_'] %}
{% set tmp = kwargs.update({'class_': kwargs['class_'] + ' validate'}) %}
{% else %}
@ -35,7 +35,7 @@
{% endif %}
<label>
{{ field.label.text }}
{{ field() }}
{{ field(*args, **kwargs) }}
<span class="lever"></span>
</label>
{% for error in field.errors %}
@ -46,18 +46,19 @@
{% macro render_decimal_range_field(field) %}
<p class="range-field">
{{ field(**kwargs) }}
{{ field(*args, **kwargs) }}
</p>
{% endmacro %}
{% macro render_file_field(field) %}
{% set placeholder = kwargs.pop('placeholder', '') %}
<div class="file-field input-field">
<div class="btn">
<span>{{ field.label.text }}</span>
{{ field(**kwargs) }}
{{ field(*args, **kwargs) }}
</div>
<div class="file-path-wrapper">
<input class="file-path validate" type="text">
<input class="file-path validate" type="text" placeholder="{{ placeholder }}">
</div>
</div>
{% endmacro %}
@ -67,7 +68,7 @@
{% if 'material_icon' in kwargs %}
<i class="material-icons prefix">{{ kwargs.pop('material_icon') }}</i>
{% endif %}
{{ field(**kwargs) }}
{{ field(*args, **kwargs) }}
{{ field.label }}
{% for error in field.errors %}
<span class="helper-text red-text">{{ error }}</span>

View File

@ -36,7 +36,7 @@
{{ M.render_field(add_job_form.description, data_length='255', material_icon='description') }}
</div>
<div class="col s12">
{{ M.render_field(add_job_form.files, accept='image/jpeg, image/png, image/tiff') }}
{{ M.render_field(add_job_form.files, accept='image/jpeg, image/png, image/tiff', placeholder='Choose your .jpeg, .png or .tiff files') }}
</div>
<div class="col s12 hide">
{{ M.render_field(add_job_form.version, material_icon='apps') }}

View File

@ -54,7 +54,7 @@
{{ M.render_field(add_job_form.description, data_length='255', material_icon='description') }}
</div>
<div class="col s12 l5">
{{ M.render_field(add_job_form.files, accept='text/plain') }}
{{ M.render_field(add_job_form.files, accept='text/plain', placeholder='Choose your .txt files') }}
</div>
<div class="col s12 l4">
{{ M.render_field(add_job_form.language, material_icon='language') }}

View File

@ -36,7 +36,7 @@
{{ M.render_field(add_job_form.description, data_length='255', material_icon='description') }}
</div>
<div class="col s12 l5">
{{ M.render_field(add_job_form.files, accept='application/pdf') }}
{{ M.render_field(add_job_form.files, accept='application/pdf', placeholder='Choose your .pdf files') }}
</div>
<div class="col s12 l4">
{{ M.render_field(add_job_form.language, material_icon='language') }}