I still get incorrect value from time or date field in nested form.
Steps to reproduce:
1. Make entity and subentity, create time and date fields in subentity
2. Put subentity in nested form with field display "In a new window"
3. Create one record in main entity and two records or more in subentity
4. In the first save, they will be parsed correctly. Try to edit one record of subentity, and any other records will break.
When I captured the values of $app_subentity_form_items in class subentity_form, here's what I got :
Code: Select all
Array
(
//24: fieldtype_nested_form
[24] => Array
(
[1] => Array
(
[25] => 2021-11-26 //25: fieldtype_input_date
[26] => 13:45 //26: fieldtype_time
)
[2] => Array
(
[25] => 1637859600
[26] => 743
)
)
Code: Select all
//fieldtype_input_date->process()
//$value = (int)get_date_timestamp($options['value']);
$value = (int)get_date_timestamp(1637859600); //saved as 209093675820 in table and displayed back as "8595-11-30"
//fieldtype_time->process()
$value = explode(':',743);
$hours = (int)$value[0]; //743
$minutes = (int)$value[1];
return ($hours*60)+$minutes; //saved as 44580 in table and displayed back as "743:00"
Code: Select all
//fieldtype_input_date->process()
//checking before conversion
$value = !is_numeric($options['value']) ? (int)get_date_timestamp($options['value']) : (int)$options['value'];
//fieldtype_time->process()
//prevent double parsing
$value = explode(':',$value);
if(count($value)>1)
{
$hours = (int)$value[0];
$minutes = (int)$value[1];
return ($hours*60)+$minutes;
}