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') }} {{ M.render_field(add_corpus_file_form.publishing_year, material_icon='access_time') }}
</div> </div>
<div class="col s12"> <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> </div>
</div> </div>

View File

@ -1,5 +1,5 @@
{% macro render_field(field) %} {% 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_'] %} {% if 'class_' in kwargs and 'validate' not in kwargs['class_'] %}
{% set tmp = kwargs.update({'class_': kwargs['class_'] + ' validate'}) %} {% set tmp = kwargs.update({'class_': kwargs['class_'] + ' validate'}) %}
{% else %} {% else %}
@ -35,7 +35,7 @@
{% endif %} {% endif %}
<label> <label>
{{ field.label.text }} {{ field.label.text }}
{{ field() }} {{ field(*args, **kwargs) }}
<span class="lever"></span> <span class="lever"></span>
</label> </label>
{% for error in field.errors %} {% for error in field.errors %}
@ -46,18 +46,19 @@
{% macro render_decimal_range_field(field) %} {% macro render_decimal_range_field(field) %}
<p class="range-field"> <p class="range-field">
{{ field(**kwargs) }} {{ field(*args, **kwargs) }}
</p> </p>
{% endmacro %} {% endmacro %}
{% macro render_file_field(field) %} {% macro render_file_field(field) %}
{% set placeholder = kwargs.pop('placeholder', '') %}
<div class="file-field input-field"> <div class="file-field input-field">
<div class="btn"> <div class="btn">
<span>{{ field.label.text }}</span> <span>{{ field.label.text }}</span>
{{ field(**kwargs) }} {{ field(*args, **kwargs) }}
</div> </div>
<div class="file-path-wrapper"> <div class="file-path-wrapper">
<input class="file-path validate" type="text"> <input class="file-path validate" type="text" placeholder="{{ placeholder }}">
</div> </div>
</div> </div>
{% endmacro %} {% endmacro %}
@ -67,7 +68,7 @@
{% if 'material_icon' in kwargs %} {% if 'material_icon' in kwargs %}
<i class="material-icons prefix">{{ kwargs.pop('material_icon') }}</i> <i class="material-icons prefix">{{ kwargs.pop('material_icon') }}</i>
{% endif %} {% endif %}
{{ field(**kwargs) }} {{ field(*args, **kwargs) }}
{{ field.label }} {{ field.label }}
{% for error in field.errors %} {% for error in field.errors %}
<span class="helper-text red-text">{{ error }}</span> <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') }} {{ M.render_field(add_job_form.description, data_length='255', material_icon='description') }}
</div> </div>
<div class="col s12"> <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>
<div class="col s12 hide"> <div class="col s12 hide">
{{ M.render_field(add_job_form.version, material_icon='apps') }} {{ 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') }} {{ M.render_field(add_job_form.description, data_length='255', material_icon='description') }}
</div> </div>
<div class="col s12 l5"> <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>
<div class="col s12 l4"> <div class="col s12 l4">
{{ M.render_field(add_job_form.language, material_icon='language') }} {{ 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') }} {{ M.render_field(add_job_form.description, data_length='255', material_icon='description') }}
</div> </div>
<div class="col s12 l5"> <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>
<div class="col s12 l4"> <div class="col s12 l4">
{{ M.render_field(add_job_form.language, material_icon='language') }} {{ M.render_field(add_job_form.language, material_icon='language') }}