magento / magento2

Prior to making any Submission(s), you must sign an Adobe Contributor License Agreement, available here at: https://opensource.adobe.com/cla.html. All Submissions you make to Adobe Inc. and its affiliates, assigns and subsidiaries (collectively “Adobe”) are subject to the terms of the Adobe Contributor License Agreement.
http://www.magento.com
Open Software License 3.0
11.54k stars 9.32k forks source link

Ui Component File Field #38908

Open thomas-kl1 opened 3 months ago

thomas-kl1 commented 3 months ago

Preconditions and environment

Steps to reproduce

Add the following field in a ui component form:

<file name="file">
            <settings>
                <label translate="true">Select File to Import</label>
                <dataScope>file</dataScope>
                <validation>
                    <rule name="required-entry" xsi:type="boolean">true</rule>
                </validation>
            </settings>
        </file>

Expected result

The form is submitted without error.

Actual result

Even if we select a file, the validation fails, like no file was selected. h 346533395-e1667aa9-ca43-4516-8b18-53967a2fc682

Additional information

No response

Release note

No response

Triage and priority

m2-assistant[bot] commented 3 months ago

Hi @thomas-kl1. Thank you for your report. To speed up processing of this issue, make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, Add a comment to the issue:

m2-assistant[bot] commented 3 months ago

Hi @engcom-November. Thank you for working on this issue. In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:

engcom-November commented 3 months ago

Hello @thomas-kl1,

Thank you for the report and collaboration!

We did not see the error while using the fileUploader component:

<field name="file">
            <argument name="data" xsi:type="array">
                <item name="config" xsi:type="array">
                    <item name="required" xsi:type="boolean">true</item>
                    <item name="validation" xsi:type="array">
                        <item name="required-entry" xsi:type="boolean">true</item>
                    </item>
                    <item name="sortOrder" xsi:type="number">333</item>
                    <item name="formElement" xsi:type="string">fileUploader</item>
                    <item name="label" xsi:type="string" translate="true">add file</item>
                </item>
            </argument>
</field>

Can you please check and let us know if this is working at your end.

Thank you.

thomas-kl1 commented 3 months ago

fileUploader and file are two different component.

The file component allows to select a file without uploading it right away.

engcom-November commented 3 months ago

It is recommended to use fileUploader, but in case if you are using file component for some specific use case, can you let us know the same.

thomas-kl1 commented 3 months ago

Could you elaborate why it's not recommended? It's not mentioned in the documentation.

I use file component because I don't feel the need to split the form submission in two parts. The file uploader component requires to have an upload ajax route. So it adds extra work to cleanup uploaded files if the user finally didn't submitted the form.

engcom-November commented 3 months ago

Yes file component can minimize the extra work needed for ajax, so confirming this issue.

github-jira-sync-bot commented 3 months ago

:white_check_mark: Jira issue https://jira.corp.adobe.com/browse/AC-12432 is successfully created for this GitHub issue.

m2-assistant[bot] commented 3 months ago

:white_check_mark: Confirmed by @engcom-November. Thank you for verifying the issue.
Issue Available: @engcom-November, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.

github-jira-sync-bot commented 3 months ago

:x: You don't have permission to export this issue.

Mohamed-Asar commented 3 months ago

@magento I am working on this