Bug #58602
closedDatepicker issue on multiple datetime fields in BE
100%
Description
After migrating our T3 Websites from 4.5 LTS to 6.2 LTS, we experienced a strange behaviour on the CE access tab for "Publish Dates and Access Rights". The datepicker for field "Expiration Date" applies the selected date in input field for "Publish Date" instead the expected input field for "Expiration Date". After some investigations we found out, that the used input id's are identical:
<input type="text" id="tceforms-datetimefield-536a4b3a16b9a" class="formField tceforms-textfield tceforms-datetimefield hasDefaultValue" name="data[tt_content][2][starttime]_hr" value=""style="width: 163px; " maxlength="20" onchange="typo3form.fieldGet('data[tt_content][2][starttime]','datetime','',1,'0');TBE_EDITOR.fieldChanged('tt_content','2','starttime','data[tt_content][2][starttime]');" />
<input type="text" id="tceforms-datetimefield-536a4b3a16b9a" class="formField tceforms-textfield tceforms-datetimefield upper-1609369200 hasDefaultValue" name="data[tt_content][2][endtime]_hr" value=""style="width: 163px; " maxlength="20" onchange="typo3form.fieldGet('data[tt_content][2][endtime]','datetime','',1,'0');TBE_EDITOR.fieldChanged('tt_content','2','endtime','data[tt_content][2][endtime]');" /><input type="hidden" name="data[tt_content][2][endtime]" value="0" />
Both id's are set to tceforms-datetimefield-536a4b3a16b9a which causes the issue. But this only happens on windows machines. Identical T3 installation moved to a Linux platform is working correct, as the ID's are unique there.
So wie investigated the code, responsible for rendering these fields in typo3\sysext\backend\Classes\Form\FormEngine.php. The referenced id is generated by PHP function uniqid. The referenced line here is 1322:
$inputId = uniqid('tceforms-' . $class . 'field-');
We found 2 ways to fix this issue on a windows machine:
1.) using the optional parameter more_entropy of function string uniqid ([ string $prefix = "" [, bool $more_entropy = false ]] ) and replacing line 1322 with$inputId = uniqid('tceforms-' . $class . 'field-', true);
2.) a second solution on windows platform is using the PHP parameters session.entropy_file and session.entropy_length.
By each of these approaches, the ID's are getting unique and the datepicker is working as expected.
For getting platform independent, we propose to change the usage of function uniqid() using the optional parameter (true) in TYPO3 core in a future release. This issue also affect TYPO3 6.1.x