Strange calendar widget behavior.
Archived from the Xataface Users forum.
TBriggs — Sun Jul 24, 2011 3:57 pm
I have 3 date fields in my database, which I want to show in mm/dd/yyyy format. As recommended in other posts, I have added functions to the file’s delegate class:
- Code: Select all
function adoption_date__display(&$record){ return date('m/d/Y', strtotime($record->strval('adoption_date'))); } function adoption_date__pullValue(&$record, $element){ return date('m/d/Y', strtotime($record->strval('adoption_date'))); }
and now the date displays as I wish. When first entering a date with the calendar widget it displays as yyyy-mm-dd, but after pressing “Save” it displays correctly. This I can live with. (I’ve tried using widget:ifFormat = “%m/%d/%Y”, but his doesn’t seem to make any difference).
However, the odd thing is that when the date field has an existing value of, say, 9/22/2009, when I click on the calendar icon it opens up at 31st March 2016!
Any idea what’s going on?
Thanks.
TBriggs — Sat Jul 30, 2011 12:35 pm
I’ve also just discovered that when the date field in the database is null, it now displays as today’s date - and loads this into the database when you update.
This is NOT good!
Anyone got any ideas, or do I have to take off the date formatting?
Thanks.
TBriggs — Thu Aug 11, 2011 4:16 pm
I’ve had to remove the data formatting in order to prevent corruption of the database.
It’s a shame I’ve had to sacrifice user-friendliness in this way.
shannah — Fri Aug 12, 2011 11:50 am
You should never implement an xxx__pullValue() method without an accompanying xxx__pushValue() method that performs the inverse operation. This will yield unexpected results.
TBriggs — Fri Aug 12, 2011 3:53 pm
I wouldn’t have thought that that would have caused null dates to display as today’s date, because the record had only been read at that point. It also doesn’t seem feasible that this would cause the data widget to interpret the date in the field into some seemingly arbitrary future date.