Hi
I have created a number of forms that enable me to edit data that was previously entered and for the most part they work fine however the datefields in the edit forms are not working. When I click into the field to update it the datepicker displays but the heading says undefined NaN and any date selected says NaN-Nan-NaN. Is there something different that I need to do to these fields to make them work?
Many thanks
I have created a number of forms that enable me to edit data that was previously entered and for the most part they work fine however the datefields in the edit forms are not working. When I click into the field to update it the datepicker displays but the heading says undefined NaN and any date selected says NaN-Nan-NaN. Is there something different that I need to do to these fields to make them work?
Many thanks
Hello gluttonforpunishment,
I'm not a Chrono professional, but after checking your new post, I think that the following links may help:
Date control using CFv5 date picker element
Adding a Datepicker for ChronoForms v5
How can I format a date in the datepicker?
How can I set a default date for a datepicker?
How can I set start and end dates for a datepicker?
P.S: I'm just an automated service😉
I'm not a Chrono professional, but after checking your new post, I think that the following links may help:
Date control using CFv5 date picker element
Adding a Datepicker for ChronoForms v5
How can I format a date in the datepicker?
How can I set a default date for a datepicker?
How can I set start and end dates for a datepicker?
P.S: I'm just an automated service😉
Hi gluttonforpunishment,
If the date value in the date field on the form does not match the datepicker field value then this may occur, you need to convert the value to the correct format before the form is displayed, this is done using a "Custom code" action before the "HTML" action:
Best regards,
Max
If the date value in the date field on the form does not match the datepicker field value then this may occur, you need to convert the value to the correct format before the form is displayed, this is done using a "Custom code" action before the "HTML" action:
<?php
$form->data["date_field_name"] = date("d-m-Y", strtotime($form->data["date_field_name"]));
Best regards,
Max
Hi Max,
Thanks for your response however I had already changed the format within the date picker field to ensure that it matches the format within the database which is y-m-d (i have lots of date fields so this was easier that custom coding them all). The datepicker does not work on the edit form even when there was no data in the record. I have renamed all of the fields in the edit form as shown in your tutorial eg model[fieldname] and am wondering if this is messing with the code for the date picker? Do i need to load some sort of event to allow the date picker to work?
Thanks for your help
Thanks for your response however I had already changed the format within the date picker field to ensure that it matches the format within the database which is y-m-d (i have lots of date fields so this was easier that custom coding them all). The datepicker does not work on the edit form even when there was no data in the record. I have renamed all of the fields in the edit form as shown in your tutorial eg model[fieldname] and am wondering if this is messing with the code for the date picker? Do i need to load some sort of event to allow the date picker to work?
Thanks for your help
I have been playing with this and the problem is being caused because when saving the original form the date picker is adding 0000-00-00 into the field when there as been no date entered, is there a way to stop this? If I delete the date and then put the curser back in the field the date picker shows correctly. If I delete 0000-00-00 and save the form it 0000-00-00 is stilled saved into the database. HAs anyone had this issue before? I have done a search but not finding anything in the forums.
Hi gluttonforpunishment,
You might want to change the database table settings so that the default value is NULL or an empty string instead of 0000-00-00
You can also add a Custom Code action to the form On Submit event to check for 0000-00-00 strings and remove them if they are found
Bob
You might want to change the database table settings so that the default value is NULL or an empty string instead of 0000-00-00
You can also add a Custom Code action to the form On Submit event to check for 0000-00-00 strings and remove them if they are found
<?php
if ( $form->data['date_input'] == '0000-00-00' ) {
form->data['date_input'] == '';
}
?>
Bob
This topic is locked and no more replies can be posted.