Skip to content

Commit

Permalink
Merge pull request #141 from aksm/ISSUE-140
Browse files Browse the repository at this point in the history
ISSUE-140: WebformMetadataDate wrongly array filters empties
  • Loading branch information
DiegoPino authored Aug 4, 2022
2 parents 080bdb8 + bcd9232 commit d3a8123
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/Plugin/WebformElement/WebformMetadataDate.php
Original file line number Diff line number Diff line change
Expand Up @@ -343,18 +343,18 @@ public function preSave(array &$element, WebformSubmissionInterface $webform_sub
// we will use this last moment to filter out those.
$newvalue = [];
if (isset($element['#multiple']) && $element['#multiple']) {
foreach ($value as $item) {
$filtered_value = array_filter($item);
// Empty elements here will carry at least the date_type making them
// not empty. So deal with that by unsetting the value completely in
// that case.
if (count($filtered_value) > 1 ) {
$newvalue[] = $item;
}
}
foreach ($value as $item) {
$filtered_value = is_array($item) ? array_filter($item) : [];
// Empty elements here will carry at least the date_type making them
// not empty. So deal with that by unsetting the value completely in
// that case.
if (count($filtered_value) > 1 ) {
$newvalue[] = $item;
}
}
}
else {
$filtered_value = array_filter($value);
$filtered_value = is_array($value) ? array_filter($value) : [];
if (count($filtered_value) > 1 ) {
$newvalue = $value;
}
Expand Down

0 comments on commit d3a8123

Please sign in to comment.