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”.

Activity

m2-assistant

m2-assistant commented on Sep 26, 2024

@m2-assistant

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.


Join Magento Community Engineering Slack and ask your questions in #github channel.
⚠️ According to the Magento Contribution requirements, all issues must go through the Community Contributions Triage process. Community Contributions Triage is a public meeting.
🕙 You can find the schedule on the Magento Community Calendar page.
📞 The triage of issues happens in the queue order. If you want to speed up the delivery of your contribution, join the Community Contributions Triage session to discuss the appropriate ticket.

added
Triage: Dev.ExperienceIssue related to Developer Experience and needs help with Triage to Confirm or Reject it
Reported on 2.4.6-p5Indicates original Magento version for the Issue report.
on Sep 26, 2024
m2-assistant

m2-assistant commented on Sep 27, 2024

@m2-assistant

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: 👇

  • 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).
    2. Verify that issue has a meaningful description and provides enough information to reproduce the issue.
    3. Add Area: XXXXX label to the ticket, indicating the functional areas it may be related to.
    4. Verify that the issue is reproducible on 2.4-develop branch
    Details- If the issue is reproducible on 2.4-develop branch, please, add the label Reproduced on 2.4.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!
    5. Add label Issue: Confirmed once verification is complete.
    6. Make sure that automatic system confirms that report has been added to the backlog.
engcom-November

engcom-November commented on Sep 27, 2024

@engcom-November
Contributor

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

github-jira-sync-bot commented on Sep 27, 2024

@github-jira-sync-bot

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

21 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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

    Participants

    @ioweb-gr@its-leofisher@engcom-Bravo@engcom-Hotel@engcom-November

    Issue actions

      Date format not respected in date ui component · Issue #39218 · magento/magento2