Skip to content

Commit bfc9dc8

Browse files
pluk77javiereguiluz
authored andcommitted
Update CrudAutocompleteSubscriber to also handle array of UUIDs correctly
1 parent 002da50 commit bfc9dc8

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/Form/EventListener/CrudAutocompleteSubscriber.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Symfony\Component\Form\FormEvent;
88
use Symfony\Component\Form\FormEvents;
99
use Symfony\Component\Uid\Ulid;
10+
use Symfony\Component\Uid\Uuid;
1011

1112
/**
1213
* @author Yonel Ceruto <[email protected]>
@@ -54,7 +55,15 @@ public function preSubmit(FormEvent $event)
5455
}
5556

5657
$data['autocomplete'] = array_map(
57-
fn ($v) => Ulid::isValid($v) ? Ulid::fromBase32($v)->toRfc4122() : $v,
58+
function ($v) {
59+
if (Ulid::isValid($v)) {
60+
return Ulid::fromBase32($v)->toRfc4122();
61+
} elseif (Uuid::isValid($v)) {
62+
return Uuid::fromString($v)->toBinary();
63+
}
64+
65+
return $v;
66+
},
5867
$data['autocomplete']
5968
);
6069
}

0 commit comments

Comments
 (0)