Skip to content

Commit

Permalink
Merge pull request #11 from acseo/fix-missing-tests-for-php-8-array-a…
Browse files Browse the repository at this point in the history
…ccess

Fix missing tests for PHP8 array access
  • Loading branch information
romainguerrero authored Oct 16, 2023
2 parents a3481ac + 7ecb2a5 commit 2384838
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Form/Field/FieldBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public function alterDataPreSetDataEvent($formFields, $builder)
//Altering date array to a \DateTime object if date type in fieldset or if date type
if ("fieldset" == $field->type) {
foreach ($field->options->subforms as $subFieldName => $subField) {
if ("date" == $subField->type && array_key_exists($name, $formData) && array_key_exists($subFieldName, $formData[$name])) {
if ("date" == $subField->type && isset($formData[$name][$subFieldName]['date'])) {
$dateTimeValue = \DateTime::createFromFormat('Y-m-d H:i:s.u', $formData[$name][$subFieldName]['date']);
// try to get the date without milliseconds
if (!$dateTimeValue) {
Expand All @@ -118,7 +118,7 @@ public function alterDataPreSetDataEvent($formFields, $builder)
} elseif ("fieldset" == $subField->type) {
//In case a fieldset contains another fieldset with date - better rewrite with recursive walker
foreach ($subField->attr->subforms as $subSubFieldName => $subSubField) {
if ("date" == $subSubField->type && array_key_exists($name, $formData) && array_key_exists($subFieldName, $formData[$name]) && array_key_exists($subSubFieldName, $formData[$name][$subFieldName])) {
if ("date" == $subSubField->type && isset($formData[$name][$subFieldName][$subSubFieldName]['date'])) {
$dateTimeValue = \DateTime::createFromFormat('Y-m-d H:i:s.u', $formData[$name][$subFieldName][$subSubFieldName]['date']);
// try to get the date without milliseconds
if (!$dateTimeValue) {
Expand Down

0 comments on commit 2384838

Please sign in to comment.