diff --git a/src/fields/Matrix.php b/src/fields/Matrix.php index 77d69ea3..fbafbde8 100644 --- a/src/fields/Matrix.php +++ b/src/fields/Matrix.php @@ -170,11 +170,16 @@ public function parseField(): mixed $index = 1; $resultBlocks = []; foreach ($expanded as $blockData) { - // all the fields are empty and setEmptyValues is off, ignore the block + // if all the fields are empty and setEmptyValues is off, ignore the block if ( !empty(array_filter( $blockData['fields'], - fn($value) => (is_string($value) && !empty($value)) || (is_array($value) && !empty(array_filter($value))) + fn($value) => ( + (is_string($value) && !empty($value)) || + (is_array($value) && !empty(array_filter($value))) || + is_bool($value) || + is_numeric($value) + ) )) ) { $resultBlocks['new' . $index++] = $blockData; diff --git a/src/fields/SuperTable.php b/src/fields/SuperTable.php index 229da422..b1c2386d 100644 --- a/src/fields/SuperTable.php +++ b/src/fields/SuperTable.php @@ -148,7 +148,13 @@ public function parseField(): mixed $preppedData[$blockIndex . '.enabled'] = true; $preppedData[$blockIndex . '.fields.' . $subFieldHandle] = $value; - if ((is_string($value) && !empty($value)) || (is_array($value) && !empty(array_filter($value)))) { + // if all the fields are empty and setEmptyValues is off, ignore the block + if ( + (is_string($value) && !empty($value)) || + (is_array($value) && !empty(array_filter($value))) || + is_bool($value) || + is_numeric($value) + ) { $allEmpty = false; }