Buy Now
Sign in

Calendar Data not populating form

vividal , January 16 at 18:36
V
vividal
I am trying to pull data from a database and populate a form. I am able to pull and populate a simple text field but I can't get a calendar field to populate.

My debug shows the data is pulled correctly as shown below but the field in form is blank. I am using the same syntax for the Value field for both items

{var:read_data4.Games.aid}
{var:read_data4.Games.start_date}

Any thoughts on what the issue might be?

thanx,
rob...

DEBUG INFO

Array
(
[read_data4] => Array
(
[log] => Array
(
[0] => SELECT `Games`.`aid` AS `Games.aid`, `Games`.`user_id` AS `Games.user_id`, `Games`.`created` AS `Games.created`, `Games`.`modified` AS `Games.modified`, `Games`.`game_start` AS `Games.game_start`, `Games`.`game_end` AS `Games.game_end`, `Games`.`away_team_id` AS `Games.away_team_id`, `Games`.`home_team_id` AS `Games.home_team_id`, `Games`.`location_id` AS `Games.location_id`, `Games`.`away_score` AS `Games.away_score`, `Games`.`home_score` AS `Games.home_score`, `Games`.`gametype_id` AS `Games.gametype_id` FROM `LO_Games` AS `Games` WHERE `Games`.`aid` = '12' LIMIT 100;
)

[var] => Array
(
[Games] => Array
(
[aid] => 12
[user_id] => 0
[created] => 0000-00-00 00:00:00
[modified] => 0000-00-00 00:00:00
[game_start] => 2018-01-12 16:30:00
[game_end] => 2018-01-12 18:00:00
[away_team_id] => 1
[home_team_id] => 4
[location_id] => 4
[away_score] =>
[home_score] =>
[gametype_id] => 1
)

)

)

)
V
vividal
So I did some more troubleshooting on this and realized I had my variables mixed up. I had
{var:read_data4.Games.start_date} and it should be
{var:read_data4.Games.game_start}.

With that fixed I still can't get it to populate the calendar field on my form. It will populate the to a text field but I need it to populate the calendar field so I can change the date/time. Any help would be greatly appreciated.
GreyHead
Hi vividal,

Do the date formats match up between the re-loaded data and the Calendar field?

Bob
ChronoForms technical support
If you'd like to buy me a coffee or two, thank you very much
V
vividal
there is no re-loaded data. It is a fresh pull on opening the form and calendar field is just blank.
V
vividal
Attached is that pulls up. Both the calendar field and the text field have the Value {var:read_data4.Games.game_start}
Attachments
temp1.jpg
temp1.jpg
(11.83 KiB)
88 Downloads/Views
V
vividal
Any insight as to what my issue is here? I really need to get this figured out.
E
emmexx
I have a similar problem. I created a thread in the CC bugs forum:
https://www.chronoengine.com/forums/posts/t104830/wrong-format-when-initialising-calendar

In my case the problem arises because I use a localised date and the db uses a standard date field.

As a workaround I use javascript:

var timeoutID;
var tmpDates = Array();

jQuery(document).ready(function() {

jQuery('[data-calendar]').each(function(i, calfield){
tmpDates.push([this.id, jQuery(calfield).val()]);
});

timeoutID = window.setTimeout(loadDates, 1000);

});

function loadDates()
{
window.clearTimeout(timeoutID);

for(var i=0; i<tmpDates.length; i++)
{
if(tmpDates[i][1] == "0000-00-00 00:00:00" || tmpDates[i][1] == "")
{
continue;
}
var parts = tmpDates[i][1].split('-');  //data
var days = parts[2].split(' ');
if(days.length==1)
{
var hours = [0, 0, 0];
} else
{
var hours = days[1].split(':');
if(hours.length < 2)
{
  hours[2] = 0;
}
}
var tmp = new Date(parts[0],parts[1]-1,days[0],hours[0],hours[1], hours[2]);

jQuery('#' + tmpDates[i][0]).closest('.field').calendar('set date', tmp);
}

}


The code could be written better but I had no time to do that.
The code saves the values of the inputs "attached" to the calendar in a js global array and starts a timer. I set 1000 ms because after that time, all the code from CC or CF is done.
The function reformats the date and sets the calendar value.
Note that the input values are there, it is the calendar "text field" that is left empty by the cegcore2 js code.

bye
maxx
V
vividal
OK I am back to working on this. I am not a programmer and dont really understand the javascript you have written. One of the things I like about CF is the simplicity it can have and I think this has to be something simple as all I am trying to do is read a calendar date into a field.

Greyhead/Admin-Any thoughts on what the issue is with this?
V
vividal
so I am getting closer on this. If I copy the "Display Format" field to use the same formatting as the "Real Format" field it displays the information.
The Real Format is YYYY-MM-DD HH:mm:ss

If I change the Display Format to be MM-DD-YYYY HH:mm:ss the field is blank.

Any thoughts?