Skip to content

Date format not respected in date ui component #39218

Open
@ioweb-gr

Description

@ioweb-gr

Preconditions and environment

  • 2.4.6-p5

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

  • Severity: S0 - Affects critical data or functionality and leaves users without workaround.
  • Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
  • Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
  • Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
  • Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.

Metadata

Metadata

Assignees

Labels

Area: Admin UIComponent: UiIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedPriority: P2A defect with this priority could have functionality issues which are not to expectations.Progress: PR in progressReported on 2.4.6-p5Indicates original Magento version for the Issue report.Reproduced on 2.4.xThe issue has been reproduced on latest 2.4-develop branchTriage: Dev.ExperienceIssue related to Developer Experience and needs help with Triage to Confirm or Reject it

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions