Replies: 7 comments 4 replies
-
I'm pretty sure we made it use ISO-8601 in order to have browsers recognize the date more consistently, especially if people opted to change the field from just a text-input to being a date-input field where the browser would render a date-picker, whether that date-picker was from the browser's internal abilities or from a 3rd party javascript tool. It's a difficult situation to solve when trying to balance UX vs DX. From a dev perspective a date-picker actually makes it easier because we can force the user to provide the date via the picker's rules that guide the user through choosing the individual date segments, so we never end up with invalid or unparseable data. BUT the typical end-user doesn't usually want a date-picker when providing their date-of-birth because they have to scroll back dozens of years, where it would be faster to simply type in the year and date. (Granted, in contrast to DOB, they may not mind a date-picker so much if they're being asked to choose an upcoming or very recent date.) |
Beta Was this translation helpful? Give feedback.
-
Having said all that, you may find that if you change the input field to a date field (to have the browser show a date-picker) instead of defaulting to a text field, it may solve whatever challenges you're facing. -<?php echo zen_draw_input_field('dob', zen_date_short($account->fields['customers_dob']), 'id="dob" placeholder="' . ENTRY_DATE_OF_BIRTH_TEXT . '"' . (ACCOUNT_DOB == 'true' && (int)ENTRY_DOB_MIN_LENGTH != 0 ? ' required' : '')); ?>
+<?php echo zen_draw_input_field('dob', zen_date_short($account->fields['customers_dob']), 'id="dob" placeholder="' . ENTRY_DATE_OF_BIRTH_TEXT . '"' . (ACCOUNT_DOB == 'true' && (int)ENTRY_DOB_MIN_LENGTH != 0 ? ' required' : ''), 'date'); ?> |
Beta Was this translation helpful? Give feedback.
-
Thank you for this detailed explanation, now I understand why this code is there. My 'challenge' was just to display date in proper format according to user's language choice. All that said, displaying ISO date in this field does not make much sense as anyway, ZC templates and even bootstrap template do not set this field as a date field. The only thing it does is preventing displaying date correctly, confusing user. |
Beta Was this translation helpful? Give feedback.
-
In the case when the field is treated as a text-only input field, how do you propose a non-standards input format be handled? In this account-edit page, this is not merely "displayed" information: it's an edit form, and the field must both display and allow editing of whatever data is supplied to it. So if you display and tell the customer to enter the date in some other format, you will need to tell Zen Cart how to parse that data in a way that can then be correctly stored into the database in a recognizable date format ... both to prevent the database from rejecting an invalid date, and to prevent the stored date from being misunderstood upon subsequent retrieval. |
Beta Was this translation helpful? Give feedback.
-
Hmmm ... the Admin has some datepicker functions. They're built for the jQueryUI datepicker used in the Admin, but perhaps they may be useful catalog-side as tools to aid in the conversion back-and-forth for the few dates used there? |
Beta Was this translation helpful? Give feedback.
-
Considering dob field does not need date-picker I test some code that, for now, is doing well. Function 'validDate' can be placed in 'functions_dates.php' or an extra file. Code is here:
This provides a good date validation and does not make any trouble when date needs to be saved in database. |
Beta Was this translation helpful? Give feedback.
-
I improved this validation to accept date with /, - or nothing as a separator. I made a GitHub branch on my repo. It will be easier to look at the code. |
Beta Was this translation helpful? Give feedback.
-
In account edit form, dob is displayed in 'Y-m-d' format whatever setting is done in language file.
Looking at 'header.php' file code, line 212, there is an explanation:
It refers to some JavaScript date picker, but there is none here... Does somebody know why it is done like that, instead of just displaying dob using short date format set in language files? Is it to accommodate some plugin?
Beta Was this translation helpful? Give feedback.
All reactions