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

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

View File

@@ -64,7 +64,7 @@ class Datalist 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;