Skip to content

Validation "required-file" or "required" does not work in the system.xml file if a field type is image. #17769

@dzima-chyzhou

Description

@dzima-chyzhou

Summary

If you create a field with the "image" type, validation "required" or "required-file" doesn't work.

Preconditions

  1. Magento 2.2.5 CE with sample data
  2. PHP 7.0.30

Steps to reproduce

  1. Create any custom module.
  2. Create system.xml configuration and add a field with image type for example:
<field id="custom" translate="label" type="image" sortOrder="40" showInDefault="1" showInStore="1" showInWebsite="1" >
   <label>Custom Label</label>
   <backend_model>Magento\Theme\Model\Design\Backend\Image</backend_model> 
   <base_url type="media" scope_info="1">vendor_module/label/custom</base_url>
   <upload_dir config="system/filesystem/media" scope_info="1">vendor_module/label/custom</upload_dir>
   <validate>required required-file</validate>
</field>
  1. Go to admin side configuration -> do not upload an image in this field -> save configuration.

Expected result

  1. The require validation error appears.

Actual result

  1. Configuration is saved without require validation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue: Format is validGate 1 Passed. Automatic verification of issue format passed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions