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.56k stars 9.32k forks source link

Date format not respected in date ui component #39218

Open ioweb-gr opened 1 month ago

ioweb-gr commented 1 month ago

Preconditions and environment

Steps to reproduce

I've created a ui component form

<form xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
    <argument name="data" xsi:type="array">
        <item name="js_config" xsi:type="array">
            <item name="provider" xsi:type="string">sync_documents_form.sync_documents_form_data_source</item>
        </item>
        <item name="label" xsi:type="string" translate="true">Sync Documents</item>
        <item name="template" xsi:type="string">templates/form/collapsible</item>
    </argument>
    <settings>
        <buttons>
            <button name="save" class="Mv\CliDocumentImporter\Block\Adminhtml\SyncDocuments\Button\Submit"/>
        </buttons>
        <namespace>sync_documents_form</namespace>
        <dataScope>data.general</dataScope>
        <deps>
            <dep>sync_documents_form.sync_documents_form_data_source</dep>
        </deps>
    </settings>
    <dataSource name="sync_documents_form_data_source" component="Magento_Ui/js/form/provider">
        <settings>
            <submitUrl path="clidocumentimporter/customer/syncsubmit"/>
        </settings>
        <dataProvider class="Mv\CliDocumentImporter\Ui\DataProvider\SyncDocuments" name="sync_documents_form_data_source">
            <settings>
                <requestFieldName>id</requestFieldName>
                <primaryFieldName>id</primaryFieldName>
            </settings>
        </dataProvider>
    </dataSource>
    <fieldset name="general">
        <settings>
            <label translate="true">General</label>
        </settings>
        <field name="id" formElement="hidden">
            <settings>
                <dataType>text</dataType>
                <dataScope>id</dataScope>
            </settings>
        </field>
        <field name="customer_ids" formElement="hidden">
            <settings>
                <dataType>text</dataType>
                <label translate="true">Customers</label>
                <dataScope>customer_ids</dataScope>
            </settings>
        </field>
        <field name="date_from" formElement="date">
            <argument name="data" xsi:type="array">
                <item name="config" xsi:type="array">
                    <item name="options" xsi:type="array">
                        <item name="showsTime" xsi:type="boolean">false</item>
                        <item name="inputDateFormat" xsi:type="string">y-MM-dd</item>
                        <item name="outputDateFormat" xsi:type="string">y-MM-dd</item>
                        <item name="pickerDateTimeFormat" xsi:type="string">y-MM-dd</item>
                    </item>
                </item>
            </argument>
            <settings>
                <dataType>timestamp</dataType>
                <label translate="true">Date From</label>
                <dataScope>date_from</dataScope>
                <validation>
                    <rule name="required-entry" xsi:type="boolean">true</rule>
                    <rule name="validate-date" xsi:type="boolean">true</rule>
                </validation>
                <notice translate="true">Enter the starting date to sync from</notice>
            </settings>
        </field>
    </fieldset>
</form>

But I notice that the date field appears with the wrong date format.

I want to force display and input value as the equivalent of php's 'Y-m-d' format.

However no matter what I put in the config options https://developer.adobe.com/commerce/frontend-core/ui-components/components/date/

the display is like this

image

And the input value is passed as seen in the screenshot.

Expected result

My field renders with the appropriate date format.

Actual result

The field appears in the wrong format.

Additional information

No response

Release note

No response

Triage and priority

m2-assistant[bot] commented 1 month ago

Hi @ioweb-gr. 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.

m2-assistant[bot] commented 1 month 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 1 month ago

Hello @ioweb-gr,

Thank you for the report and collaboration!

Verified this issue on 2.4-develop, and it's reproduced. When creating a ui component of date field, the date format is not being changed as specified.

Please take a look at the screenshot: Even though the date format is specified as y-MM-dd the default format is rendered.

image

Hence confirming this.

Please find the module used to reproduce this issue. I39218V.zip

Thank you.

github-jira-sync-bot commented 1 month ago

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

m2-assistant[bot] commented 1 month 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.

ioweb-gr commented 1 month ago

Additionally it's not just the presentation it's also the actual value passed

its-leofisher commented 1 month ago

@magento I am working on this

m2-assistant[bot] commented 1 month ago

Hi @its-leofisher! :wave: Thank you for collaboration. Only members of Community Contributors Team are allowed to be assigned to the issue. Please use @magento add to contributors team command to join Contributors team.

its-leofisher commented 1 month ago

@magento add to contributors team

m2-assistant[bot] commented 1 month ago

Hi @its-leofisher! :wave: Thank you for joining. Please accept team invitation :point_right: here :point_left: and add your comment one more time.

its-leofisher commented 1 month ago

@magento I am working on this