Skip to content

Commit

Permalink
EZP-29119: Display proper validation error message when non-image fil…
Browse files Browse the repository at this point in the history
…e uploaded in image FieldType
  • Loading branch information
mikadamczyk committed Jun 15, 2018
1 parent e76fd81 commit 3179c75
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@
this.fieldContainer.querySelector(SELECTOR_DATA).removeAttribute('hidden');
this.fieldContainer.querySelector(SELECTOR_PREVIEW).setAttribute('hidden', true);
this.fieldContainer.classList.remove('is-invalid');
[...this.fieldContainer.querySelectorAll('.ez-field-edit__error')].forEach(element => element.remove());

btnRemove.removeEventListener('click', this.handleRemoveFile);

Expand Down
5 changes: 5 additions & 0 deletions src/bundle/Resources/views/fieldtypes/edit/ezimage.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
{% set preview_block_name = 'ezimage_preview' %}
{% set max_file_size = min(form.parent.vars.value.fieldDefinition.validatorConfiguration.FileSizeValidator.maxFileSize * 1024 * 1024, max_upload_size|round) %}
{% set attr = attr|merge({'accept': 'image/*'}) %}
{% for error in form.parent.parent.parent.vars.errors %}
{% if error.origin == form.vars.errors.form %}
{% set errors = errors|default({})|merge({0: error}) %}
{% endif %}
{% endfor %}
{{ block('binary_base_row') }}
{%- endblock -%}

Expand Down

0 comments on commit 3179c75

Please sign in to comment.