Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Date Picker in ModelAdmin search fields?


Go to End


17 Posts   7833 Views

Avatar
swaiba

Forum Moderator, 1899 Posts

12 October 2010 at 3:34am

Avatar
swaiba

Forum Moderator, 1899 Posts

13 October 2010 at 12:31am

I've added both...

i18n::set_locale('en_GB');
i18n::set_date_format('YYYY-mm-dd');

to my config and it *still* saves '2010-10-30' (October 30th 2010) as '2010-01-30' (January 30th 2010).

I waited 6 months with legacy datetime fields and figured this is ironed out now... Can anyone please help me use 2.4.2 for uk dates with the datepicker in model admin?

Avatar
dalesaurus

Community Member, 283 Posts

13 October 2010 at 3:24am

The second date is how things are required to be saved in MySQL date fields, that is why there is a separation between the *data* format and the *date* format (with the latter being wrangled by Zend_Date).

So please specify; are you saying dates are being saved correctly in the DB but localized incorrectly when populated in forms? Or are the wrong dates being saved into the DB?

I'm sorry to disappoint, but if you have followed the development of the date field upgrades they are now functional in 2.4.2 but are by no means complete. Ingo has put in a lot of time but it is still going to be another release cycle before they start really shaping up (ie. pluggable libraries, more complete internationalization through Zend_Date, thorough JS validation).

Avatar
swaiba

Forum Moderator, 1899 Posts

13 October 2010 at 3:42am

To confirm:
1)create new record
2)hit field and calendar appears, I select October 30th 2010
3)'2010-10-30' is shown in the textfield
4)I hit save
5)'2010-01-30' is shown in the text field and is also saved in the db

I can go to the DB and change the date manually - it is perfectly capable of saving that date and it the software can read the value and use it as October 30th.

Well I guess I am not that close, but I did notice some issues I'd raised seem to have been fixed that relate to times and dates (and chrome) but I hadn't read over the release notices / developers list too closely. I do of course appreciate all the work which is done on silverstirpe by Ingo, Will, Sean and everyone else.

Barry

Avatar
dalesaurus

Community Member, 283 Posts

13 October 2010 at 4:14pm

Interesting, have you updated to the latest code? It seems there was a fairly recent checkin that addresses an issue that sounds exactly like what you're seeing;

http://open.silverstripe.org/wiki/ChangeLog/2.4.2

http://open.silverstripe.org/ticket/5931

Avatar
swaiba

Forum Moderator, 1899 Posts

13 October 2010 at 9:13pm

I am using 2.4.2

Avatar
dalesaurus

Community Member, 283 Posts

14 October 2010 at 3:09am

I have just tested en_GB on both 2.4.2 and SVN with the defaults and not setting any additional configs on the date picker. The code I wrote also used the stock scaffolded form via the model admin. I was able to save dates of all ranges without issue.

I am not sure where to direct you from here. At this point it might be a matter of walking the code and using Debug::show() and die() step by step until you identify where it is going awry. Sorry I could not be of more help.

Avatar
swaiba

Forum Moderator, 1899 Posts

14 October 2010 at 3:19am

no worries, it might be something todo with the underlying zend locale, but for now I've just rolled back to using the legacy module - until I have more time.