Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in forms with date inputs in german format #27265

Closed
NeilofSteel opened this issue Mar 12, 2020 · 17 comments
Closed

Error in forms with date inputs in german format #27265

NeilofSteel opened this issue Mar 12, 2020 · 17 comments
Assignees
Labels
Reported on 2.3.4 Indicates original Magento version for the Issue report.

Comments

@NeilofSteel
Copy link

NeilofSteel commented Mar 12, 2020

Preconditions (*)

  1. Magento 2.3.4
  2. Using locale de_DE

Steps to reproduce (*)

  1. Use Magento 2.3.4
  2. Set your Interface user and shop locale to germany
  3. Edit customer in backend or go to create account in frontend
  4. Pick for example the birthdate 30.01.1999

Expected result (*)

  1. Save customer or create account with no error in the date input

Actual result (*)

  1. Getting error under the birthday date input "The Date of Birth should not be greater than today." and can't save the customer information or create a account.

I think the reason for that are the "." characters which we are using in dates in germany. -> dd.mm.yyyy
If I set my user Interface-Locale to en_US it works with the format dd/mm/yyyy

@m2-assistant
Copy link

m2-assistant bot commented Mar 12, 2020

Hi @NeilofSteel. Thank you for your report.
To help us process this issue please make sure that you provided the following information:

  • Summary of the issue
  • Information on your environment
  • Steps to reproduce
  • Expected and actual results

Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:

@magento give me 2.4-develop instance - upcoming 2.4.x release

For more details, please, review the Magento Contributor Assistant documentation.

@NeilofSteel do you confirm that you were able to reproduce the issue on vanilla Magento instance following steps to reproduce?

  • yes
  • no

@magento-engcom-team magento-engcom-team added the Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed label Mar 12, 2020
@NeilofSteel
Copy link
Author

@magento give me 2.4-develop instance

@magento-engcom-team
Copy link
Contributor

Hi @NeilofSteel. Thank you for your request. I'm working on Magento 2.4-develop instance for you

@magento-engcom-team
Copy link
Contributor

Hi @NeilofSteel, here is your Magento instance.
Admin access: https://i-27265-2-4-develop.instances.magento-community.engineering/admin_71e1
Login: 5c7e0e6c Password: 89f28faae902
Instance will be terminated in up to 3 hours.

@NeilofSteel
Copy link
Author

@magento give me 2.3.4 instance

@magento-engcom-team
Copy link
Contributor

Hi @NeilofSteel. Thank you for your request. I'm working on Magento 2.3.4 instance for you

@magento-engcom-team
Copy link
Contributor

Hi @NeilofSteel, here is your Magento instance.
Admin access: https://i-27265-2-3-4.instances.magento-community.engineering/admin_573e
Login: 979805af Password: ba91b79a4b6a
Instance will be terminated in up to 3 hours.

@NeilofSteel
Copy link
Author

Well only reproduceable in 2.3.4 is there a fix?
already tried #27027 but not working for me

@devchris79
Copy link

May be worth checking #26675

@Axel29
Copy link

Axel29 commented Mar 24, 2020

Any update on this issue? Having the same issue with French locale, customers can't create an account.
Thanks.

@Axel29
Copy link

Axel29 commented Mar 24, 2020

After debugging a little, it seems that if we make the following changes:

  • \Magento\Customer\Block\Widget\Dob::getHtmlExtraParams :
public function getHtmlExtraParams()
{
    $validators = [];
    if ($this->isRequired()) {
        $validators['required'] = true;
    }
    $validators['validate-date'] = [
        'dateFormat' => $this->getDateFormat()
    ];
    /*
     * The patch is here.
     * Original code: $validators['validate-dob'] = true;
     */
    $validators['validate-dob'] = [
        'dateFormat' => $this->getDateFormat()
    ];

    return 'data-validate="' . $this->_escaper->escapeHtml(json_encode($validators)) . '"';
}
  • view/frontend/web/js/validation.js :
define([
    'jquery',
    'moment',
    'jquery/validate',
    'mage/translate'
], function ($, moment) {
    'use strict';

    $.validator.addMethod(
        'validate-dob',
        function (value, param, params) {
            if (value === '') {
                return true;
            }

            return moment.utc(value, params.dateFormat).isBefore(moment.utc());
        },
        $.mage.__('The Date of Birth should not be greater than today.')
    );
});

It's almost good.
The only thing left is that the date format doesn't seem to be okay.
The correct one would be D/MM/Y but Magento returns "dd/MM/y".

@stkrelax
Copy link

Also reproduced on magento 2.3.5-p1. Same Problem here. No account create possible...

@stkrelax
Copy link

@Axel29 there is also a validation in vendor/magento/module-ui/view/base/web/js/lib/validation/rules.js where it is used

@hostep
Copy link
Contributor

hostep commented Jul 2, 2020

I think this got fixed in 2.4-develop with MC-31117 in scope of #26700, but might be wrong about this.

@NeilofSteel
Copy link
Author

To fix my issue I changed the line

return moment(value).isBefore(moment());
to
return moment(value, ["D.MM.Y"]).isBefore(moment());

in /vendor/magento/module-customer/view/frontend/web/js/validation.js

but you should only do that if you use that format too :)

@ghost ghost added Issue: ready for confirmation and removed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed labels Oct 21, 2020
@engcom-Bravo engcom-Bravo self-assigned this Oct 21, 2020
@m2-assistant
Copy link

m2-assistant bot commented Oct 21, 2020

Hi @engcom-Bravo. 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).

    DetailsIf the issue has a valid description, the label Issue: Format is valid will be added to the issue automatically. Please, edit issue description if needed, until label Issue: Format is valid appears.

  • 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add Issue: Clear Description label to the issue by yourself.

  • 3. Add Component: XXXXX label(s) to the ticket, indicating the components it may be related to.

  • 4. Verify that the issue is reproducible on 2.4-develop branch

    Details- Add the comment @magento give me 2.4-develop instance to deploy test instance on Magento infrastructure.
    - 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-Bravo
Copy link
Contributor

Hello @NeilofSteel

Thank you for your report

We have rechecked the issue on the latest 2.4-develop and the issue is not reproducible

Steps to reproduce:

  1. Set your Interface user and shop locale to Germany
    Interface locale
  2. Edit customer in backend or go to create account in frontend
  3. Pick for example the birthdate 30.01.1999
    Edit data
    Create acc

Actual result: Save customer or create account with no error in the date input

We are closing this issue. Please feel free to comment, reopen or create new ticket according to the Issue reporting guidelines

@magento-engcom-team magento-engcom-team added the Reported on 2.3.4 Indicates original Magento version for the Issue report. label Nov 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Reported on 2.3.4 Indicates original Magento version for the Issue report.
Projects
None yet
Development

No branches or pull requests

8 participants