strange behaviour with calendar widget (date formatting)

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

strange behaviour with calendar widget (date formatting)

Postby razzetto » Tue Sep 04, 2012 6:40 am

Hi Steve, hi all.

I have some problems with time fields (and tried different solutions, perhaps messing everything).

To avoid showing 01-01-1970 when the field is NULL, i entered, in the application delegate class for the table :

Code: Select all
function data_intervento__display(&$record){
   if ($record->val('data_intervento') == NULL){
      return "";
}
   else {
      return date('d-m-Y', strtotime($record->strval('data_intervento')));
}
}

and everything (in list and details views) works well.
switching to the edit view i had some problems: the date was always on the format Y-m-d; so i changed the setting in fields.ini for the widget:

Code: Select all
[data_intervento]
widget:type=calendar
widget:ifFormat = %d-%m-%Y


but now i get a messy situation:
- when i enter the day with the calendar the field space is formatted good. (it lacks the red square, though, and it's a required field)
for example if i enter the date of today, the field gets filled with 04-09-2012
-when i click on save, the field shows 2012-09-04.

this would be acceptable (not a great issue, come on), but..
if i now click on the calendar widget, it shows the date 05-03-2010 as a preselected date. mmmhhh.

if i comment out the calendar widget in fields.ini this strange calendar behaviour disappears, but of course i would get, in the edit view, the format Y-m-d.


any suggestions, ideas on why this happens? i really can't get a clear view of the situation


Thanks,

Paolo
razzetto
 
Posts: 16
Joined: Thu Jul 12, 2012 6:58 pm

Re: strange behaviour with calendar widget (date formatting)

Postby razzetto » Tue Sep 04, 2012 6:52 am

ok. i found the solution here http://xataface.com/forum/viewtopic.php?f=5&t=4245&start=0

i just needed to add
Code: Select all
function data_intervento__pullValue(&$record, $element){
    return date('d-m-Y', strtotime($record->strval('data_intervento')));


just to be sure....

in this case, i wonder, do i need a push_value definition?

thanks,

Paolo
razzetto
 
Posts: 16
Joined: Thu Jul 12, 2012 6:58 pm

Re: strange behaviour with calendar widget (date formatting)

Postby shannah » Sat Sep 08, 2012 10:32 am

Yes. I think you do need a pushValue definition also.
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm


Return to Xataface Users

Who is online

Users browsing this forum: No registered users and 9 guests

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