-
Notifications
You must be signed in to change notification settings - Fork 35
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
Date elements: implement date format selection #1
Comments
you can change this behavoir with attributes. "pattern" => "\d{2}.\d{2}.\d{4}", "placeholder" => "DD.MM.YYYY". But i think its good to implement presets for this. Lets keep this issue opened. |
Thanks for this hint. Ooops - sorry. I closed it? Please re-open again. |
one more good point. i need to cover that in the documentation |
I now did use these patterns. And the field shows (and only accepts) the correct format as input according to the pattern provided. I checked the date validation script which uses RegExp according to the provided pattern attribut. But: the form field "Date" re-formats the date into US format after submit (seen in the POST values). So according to my understanding the RegExp shall not use the pattern attribute provided but use the standard US format. Could you please have a look to this? |
can you please reset your session/change form id and try again? I just tried to reproduce and cant reproduce that.
|
Hmmmm. I am using this field definition:
This is what I receive after submit: this is your Element\Date - Script
The original syntax did not work for me as the POST value always return YYYY-MM-DD. I do not know if any browser returns the date value this way. Could you reproduce this too? |
oh, i thought that validation were failing. let me see the value. |
in firefox + your element configuration im getting a valid status with a value '01.01.2001'. After googling it seems that it is impossible to specify chrome what date format to use, it will always fallback to a format what locale locale will specify. So it seems that you need to stick with a Textbox field to get 100% working code with EU format instead of date |
i think a way to is to change type=date to type=input as in reality only chrome 'supports' it.
|
Ooops - now you were quicker than me... Using a text field input was my first thought too. So I again checked browsers and I agree that FF returns DD.MM.YYYY (according to But that's why I am thinking it would be a good idea to implement a switch before validating into the date-element. Or try to reformat the POST value in a way like: input2date()$_POST["date"] |
I now also was trying your recommendation to change field to text. So we need to agree on a compromise. Or do you find another smart solution? |
i just commited a correct validation for a Date. Im not sure what to do with a firefox users. seems The best way is to stick with a US format for them, so you wont need to guess if value were in US or EU format. what do you think? |
from another hand, we can try to rewrite the value in validation function to the needed format.
|
Form::Date ("Geburtsdatum:", "gebdat", array("required" => 1,
"shortDesc" => "Bitte das Eingabeformat beachten.",
"format" => "EU",
"placeholder" => "TT.MM.JJJJ",
"title" => "TT.MM.JJJJ (Beispiel: 11.05.1975)")); Form::Date ("Geburtsdatum:", "gebdat", array("required" => 1,
"shortDesc" => "Bitte das Eingabeformat beachten.",
"format" => "US",
"placeholder" => "MM/TT/JJJJ",
"title" => "MM/TT/JJJJ (Beispiel: 05/11/1975)")); |
OK
I think best would be to stay with patterns (instead of introducing "format"). This way everybody can put in his own pattern instead just having two "formats". And even if there are only these two. With the pattern you know exactly what to expect. According to my (todays) thoughts - Just keep the solution as it is right now in Github (please think on versioning in case somebody already download 4.0) ;-) even if just one file has been changed slightly. Thanks for your help and discussion. |
ok. lets wait till next bugreport 'Date returned in wrong format'. I have changed version to 4.0-trunk, to identify that its not a release. |
For Date fields it often is useful to have the input validated in the local format. So DD.MM.YYYY instead of the US format.
Is there a way to adjust this already?
The text was updated successfully, but these errors were encountered: