oxodesign
oxodesign
FFilament
Created by oxodesign on 9/30/2024 in #❓┊help
Custom form field, how to change the state from x-init?
I have following component and want to change the state from inside the function?
<x-dynamic-component
:component="$getFieldWrapperView()"
:field="$field"
>
<div
x-data="{ state: $wire.$entangle('{{ $getStatePath() }}') }"
>
<input x-model="state" x-ref="test_input" x-init="await doSomething();" />
</div>

<script>
async function doSomething() {
// How can I change the state from inside here?
}
</script>
</x-dynamic-component>
<x-dynamic-component
:component="$getFieldWrapperView()"
:field="$field"
>
<div
x-data="{ state: $wire.$entangle('{{ $getStatePath() }}') }"
>
<input x-model="state" x-ref="test_input" x-init="await doSomething();" />
</div>

<script>
async function doSomething() {
// How can I change the state from inside here?
}
</script>
</x-dynamic-component>
Thanks in advance
2 replies