Skip to content
This repository was archived by the owner on Mar 18, 2025. It is now read-only.

Commit 742d918

Browse files
committed
Prevent input rendering string '[]' when name is omitted
1 parent e8f1ee1 commit 742d918

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

resources/views/components/inputs/input.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
@if ($id) id="{{ $id }}" @endif
1010
type="{{ $type }}"
1111

12-
@if ($value && ! $attributes->whereStartsWith('wire:model')->first()) value="{{ $value }}" @endif
12+
@if (! is_null($value) && ! $attributes->whereStartsWith('wire:model')->first()) value="{{ $value }}" @endif
1313

1414
@if ($hasErrorsAndShow($name))
1515
aria-invalid="true"

resources/views/components/inputs/textarea.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
@endif
1414

1515
{!! $attributes->merge(['class' => $inputClass(), 'rows' => 3]) !!}
16-
>@if (($slot || $value) && ! $attributes->whereStartsWith('wire:model')->first()){!! $value ?? old($name, $slot) !!}@endif</textarea>
16+
>@if (($slot || ! is_null($value)) && ! $attributes->whereStartsWith('wire:model')->first()){!! $value ?? old($name, $slot) !!}@endif</textarea>
1717

1818
@include('form-components::partials.trailing-addons')
1919
</div>

src/Components/Inputs/Input.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function __construct(
3737
public $extraAttributes = '',
3838
) {
3939
$this->id = $this->id ?? $this->name;
40-
$this->value = old($this->name, $this->value);
40+
$this->value = $this->name ? old($this->name, $this->value) : $this->value;
4141
$this->resolveMaxWidth();
4242

4343
$this->showErrors = $showErrors;

0 commit comments

Comments
 (0)