Strange calendar widget behavior.

A place for users and developers of the Xataface to discuss and receive support.

Strange calendar widget behavior.

Postby 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
 
Posts: 47
Joined: Mon Mar 02, 2009 6:38 am
Location: Gulfport, FL

Re: Strange calendar widget behavior.

Postby 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
 
Posts: 47
Joined: Mon Mar 02, 2009 6:38 am
Location: Gulfport, FL

Re: Strange calendar widget behavior.

Postby 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.
TBriggs
 
Posts: 47
Joined: Mon Mar 02, 2009 6:38 am
Location: Gulfport, FL

Re: Strange calendar widget behavior.

Postby 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.
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Re: Strange calendar widget behavior.

Postby 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.
TBriggs
 
Posts: 47
Joined: Mon Mar 02, 2009 6:38 am
Location: Gulfport, FL


Return to Xataface Users

Who is online

Users browsing this forum: No registered users and 27 guests

cron
Powered by Dataface
© 2005-2007 Steve Hannah All rights reserved