F
Filament2mo ago
Gush

How to work with State as a array?

<x-dynamic-component
:component="$getFieldWrapperView()"
:field="$field"
>
<div x-data="{ state: $wire.$entangle('{{ $getStatePath() }}') }">
<input type="number" x-model="state.0" />
<input type="number" x-model="state.1" />
</div>
</x-dynamic-component>
<x-dynamic-component
:component="$getFieldWrapperView()"
:field="$field"
>
<div x-data="{ state: $wire.$entangle('{{ $getStatePath() }}') }">
<input type="number" x-model="state.0" />
<input type="number" x-model="state.1" />
</div>
</x-dynamic-component>
No description
Solution:
Did you pass an empty array as the initial state?
Jump to solution
4 Replies
slamx_
slamx_2mo ago
Did you try x-model="state[0]" ?
Gush
Gush2mo ago
yeah gives null too
Solution
Dennis Koch
Dennis Koch2mo ago
Did you pass an empty array as the initial state?
Gush
Gush2mo ago
just did
x-init="state = [];"
x-init="state = [];"
5 minutes ago, crazy how after a full morning it was as simple as this