refactor: replace random ID generation with Cuid2 for unique HTML IDs in form components

This commit is contained in:
Andras Bacsai committed 2025-10-16 12:54:14 +02:00
1 parent a5c6f53b58
commit d2a334df78
5 files changed
+6 -6

No files matched your search

+1 -1
View File
@@ -57,7 +57,7 @@ class Select extends Component
// This prevents duplicate IDs when multiple forms are on the same page
if ($this->modelBinding && $this->modelBinding !== 'null') {
// Use original ID with random suffix for uniqueness
$uniqueSuffix = substr(md5(uniqid((string) mt_rand(), true)), 0, 8);
$uniqueSuffix = new Cuid2;
$this->htmlId = $this->modelBinding.'-'.$uniqueSuffix;
} else {
$this->htmlId = (string) $this->id;