An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.
PHP coolifydatabasesdeploymentdockerdocker-composeinertiajslaravelmariadbmysqlnextjsnodejsphppostgresredisself-hostedself-hostingserverstatic-sitesveltesvelte5
Fix wire:model warnings and ensure truly unique HTML IDs
Andras Bacsai598984f29141
diff --git a/app/View/Components/Forms/Checkbox.php b/app/View/Components/Forms/Checkbox.phpindex d96e385f76..a759164fbb 100644--- a/app/View/Components/Forms/Checkbox.php+++ b/app/View/Components/Forms/Checkbox.php@@ -53,14 +53,14 @@ class Checkbox extends Component{// Store original ID for wire:model binding (property name)$this->modelBinding = $this->id;- $this->htmlId = $this->id;- // Generate unique HTML ID by prefixing with Livewire component ID if available+ // Generate unique HTML ID by adding random suffix+ // This prevents duplicate IDs when multiple forms are on the same pageif ($this->id) {- $livewireId = $this->attributes?->wire('id');- if ($livewireId) {- $this->htmlId = $livewireId.'-'.$this->id;- }+ $uniqueSuffix = substr(md5(uniqid((string) mt_rand(), true)), 0, 8);+ $this->htmlId = $this->id.'-'.$uniqueSuffix;+ } else {+ $this->htmlId = $this->id;}return view('components.forms.checkbox');diff --git a/app/View/Components/Forms/Datalist.php b/app/View/Components/Forms/Datalist.phpindex e5bbbfb5cb..08a320f687 100644--- a/app/View/Components/Forms/Datalist.php+++ b/app/View/Components/Forms/Datalist.php@@ -56,20 +56,22 @@ class Datalist extends Componentif (is_null($this->id)) {$this->id = new Cuid2;- $this->modelBinding = $this->id;+ // Don't create wire:model binding for auto-generated IDs+ $this->modelBinding = 'null';}- // Generate unique HTML ID by prefixing with Livewire component ID+ // Generate unique HTML ID by adding random suffix// This prevents duplicate IDs when multiple forms are on the same page- $livewireId = $this->attributes?->wire('id');- if ($livewireId && $this->modelBinding) {- $this->htmlId = $livewireId.'-'.$this->modelBinding;+ if ($this->modelBinding && $this->modelBinding !== 'null') {+ // Use original ID with random suffix for uniqueness+ $uniqueSuffix = substr(md5(uniqid((string) mt_rand(), true)), 0, 8);+ $this->htmlId = $this->modelBinding.'-'.$uniqueSuffix;} else {- $this->htmlId = $this->modelBinding ?: $this->id;+ $this->htmlId = (string) $this->id;}if (is_null($this->name)) {- $this->name = $this->modelBinding;+ $this->name = $this->modelBinding !== 'null' ? $this->modelBinding : (string) $this->id;}return view('components.forms.datalist');diff --git a/app/View/Components/Forms/Input.php b/app/View/Components/Forms/Input.phpindex 37c126c0e3..9a0c87c0ab 100644--- a/app/View/Components/Forms/Input.php+++ b/app/View/Components/Forms/Input.php@@ -52,19 +52,22 @@ class Input extends Componentif (is_null($this->id)) {$this->id = new Cuid2;- $this->modelBinding = $this->id;+ // Don't create wire:model binding for auto-generated IDs+ $this->modelBinding = 'null';}- // Generate unique HTML ID by prefixing with Livewire component ID++ // Generate unique HTML ID by adding random suffix// This prevents duplicate IDs when multiple forms are on the same page- $livewireId = $this->attributes?->wire('id');- if ($livewireId && $this->modelBinding) {- $this->htmlId = $livewireId.'-'.$this->modelBinding;+ if ($this->modelBinding && $this->modelBinding !== 'null') {+ // Use original ID with random suffix for uniqueness+ $uniqueSuffix = substr(md5(uniqid((string) mt_rand(), true)), 0, 8);+ $this->htmlId = $this->modelBinding.'-'.$uniqueSuffix;} else {- $this->htmlId = $this->modelBinding ?: $this->id;+ $this->htmlId = (string) $this->id;}if (is_null($this->name)) {- $this->name = $this->modelBinding;+ $this->name = $this->modelBinding !== 'null' ? $this->modelBinding : (string) $this->id;}if ($this->type === 'password') {$this->defaultClass = $this->defaultClass.' pr-[2.8rem]';diff --git a/app/View/Components/Forms/Select.php b/app/View/Components/Forms/Select.phpindex c0811b5bd9..54d83ded74 100644--- a/app/View/Components/Forms/Select.php+++ b/app/View/Components/Forms/Select.php@@ -49,20 +49,22 @@ class Select extends Componentif (is_null($this->id)) {$this->id = new Cuid2;- $this->modelBinding = $this->id;+ // Don't create wire:model binding for auto-generated IDs+ $this->modelBinding = 'null';}- // Generate unique HTML ID by prefixing with Livewire component ID+ // Generate unique HTML ID by adding random suffix// This prevents duplicate IDs when multiple forms are on the same page- $livewireId = $this->attributes?->wire('id');- if ($livewireId && $this->modelBinding) {- $this->htmlId = $livewireId.'-'.$this->modelBinding;+ if ($this->modelBinding && $this->modelBinding !== 'null') {+ // Use original ID with random suffix for uniqueness+ $uniqueSuffix = substr(md5(uniqid((string) mt_rand(), true)), 0, 8);+ $this->htmlId = $this->modelBinding.'-'.$uniqueSuffix;} else {- $this->htmlId = $this->modelBinding ?: $this->id;+ $this->htmlId = (string) $this->id;}if (is_null($this->name)) {- $this->name = $this->modelBinding;+ $this->name = $this->modelBinding !== 'null' ? $this->modelBinding : (string) $this->id;}return view('components.forms.select');diff --git a/app/View/Components/Forms/Textarea.php b/app/View/Components/Forms/Textarea.phpindex cad85e1670..e962efc291 100644--- a/app/View/Components/Forms/Textarea.php+++ b/app/View/Components/Forms/Textarea.php@@ -62,20 +62,22 @@ class Textarea extends Componentif (is_null($this->id)) {$this->id = new Cuid2;- $this->modelBinding = $this->id;+ // Don't create wire:model binding for auto-generated IDs+ $this->modelBinding = 'null';}- // Generate unique HTML ID by prefixing with Livewire component ID+ // Generate unique HTML ID by adding random suffix// This prevents duplicate IDs when multiple forms are on the same page- $livewireId = $this->attributes?->wire('id');- if ($livewireId && $this->modelBinding) {- $this->htmlId = $livewireId.'-'.$this->modelBinding;+ if ($this->modelBinding && $this->modelBinding !== 'null') {+ // Use original ID with random suffix for uniqueness+ $uniqueSuffix = substr(md5(uniqid((string) mt_rand(), true)), 0, 8);+ $this->htmlId = $this->modelBinding.'-'.$uniqueSuffix;} else {- $this->htmlId = $this->modelBinding ?: $this->id;+ $this->htmlId = (string) $this->id;}if (is_null($this->name)) {- $this->name = $this->modelBinding;+ $this->name = $this->modelBinding !== 'null' ? $this->modelBinding : (string) $this->id;}// $this->label = Str::title($this->label);