Skip to content

Commit

Permalink
🩹 fix: Set group default
Browse files Browse the repository at this point in the history
  • Loading branch information
tombroucke committed Oct 28, 2024
1 parent 8d4b8ca commit 159f6c3
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/Fields/Group.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,27 @@

namespace Otomaties\AcfObjects\Fields;

use Otomaties\AcfObjects\Contracts\CollectionContract;

class Group extends Collection
{
public static function prepareData(mixed $data): mixed
public function default(mixed $values): CollectionContract
{
if ($this->isEmpty()) {
$this->items = $values;
} else {
foreach ($values as $key => $value) {
if (! isset($this->items[$key])) {
$this->items[$key] = $value;
}
}
}

return $this;
}

public static function prepareData(mixed $data): mixed
{
if (is_bool($data) && ! $data) {
$data = [];
}
Expand Down

0 comments on commit 159f6c3

Please sign in to comment.