Found something funny. The date completion on tab for datefields is a great and brilliant feature, but it behaves strange depending on what I type,
if I type 05 for the day and hit tab, the correct complete date will be filled out, but if i type 2007 as the year and tab, the date becomes 2008-08-07 (wrong result, should be 2007-currentmonth-currentday).
Ex:
05 : translates to 2007-09-05 (current year, date and the day i typed = correct)
2007: translates to 2008-08-07 (or similar depending on day/month)
07-09: translates to 2007-07-09 (should be 2007-09- I think)
this is my setup for the field:
var dt = new Ext.form.DateField({
fieldLabel: Date,
name: 'ActivityDate',
format: 'Y-m-d',
value: new Date().format('Y-m-d'),
allowBlank: false,
width:100
});
Can it be configured to behave the way I want, or only to complete the date if theres 1 or 2 chars in the field? Or is this parser related to the default format ('m/d/y') and because my local format setting?
/Fredrik
Nice input on this! I really didn't reflect if one behavior is more logical than another... I just expected it to complete the date and resolve any missing parts (year-month-day), from left to right, based on the current date (and specified format). But then the completion for ‘07’ wouldn’t be logical, right? And it is still the preferred behavior imho :)
But I still think 2007 -> 2008-08-7 is a bit wierd :)
Both 2007-09-05' and '07-09-05' are common formats in for example Sweden, and a config for expanding 07-09-05 to 2007-09-05 (on blur or similar) would be I deal (forceFullDate).
(but is parhaps overkill and something that can be/should be implemented outside the scope of Ext).
Jack, now I understand the logic behind it, I thought it was based on the fields date pattern. I think I’ll ask my users how they want it to behave.
Mystix, cool solution! very handy if you know the days but not the actual date
Thanks for the input and suggestions!
/Fredrik
you could also take a look at what another user @bgauthier has done:
http://extjs.com/forum/showthread.php?t=10248
You may also want to take a look at altFormats config which is what is used to parse those dates. I would imagine you could edit them (and their order) to make it behaved how you wish.
/**
* @cfg {String} altFormats
* Multiple date formats separated by "" to try when parsing a user input value and it doesn't match the defined
* format (defaults to 'm/d/Ym-d-ym-d-Ym/dm-dd').
*/
altFormats : "m/d/Ym-d-ym-d-Ym/dm-dmdmdymdYd"
First off, I think most people would reasonably expect '07-09' to parse as 'July 9' (assuming m-d culture) and not '2007 September, [current day].' I guess it's arguable, but it seems to me that assuming m-d format makes a lot more sense than Y-m when you enter two numbers with one separator.
Regarding parsing of '2007,' I have a hard time considering this as a bug. I'm not sure why anyone would expect '2007' in a full date field to equal today's date. It doesn't match any reasonable pattern for a complete date, so it would be just as reasonable to simply throw an error or, as it does, just take its best guess based on available formats. Yes, we could probably add special logic to handle this case, but why? It's not really a valid use case for a date field IMO.
Anyway, if you'd like to override the parsing behavior, take a look at the DateField's altFormats config. It allows you to specify a series of different formats that will be used while attempting to parse the value if the default format config doesn't match. Maybe you can add 'Y' to it (I haven't tried).
Allergies.. no relief?!?
Religion in the workplace? |