Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

vincent15000's avatar

Livewire radio button

Hello,

I have this code.

<div class="flex flex-col gap-1">
    <x-form.label>Type</x-form.label>

    @foreach (['list', 'image'] as $type)
        <fieldset class="ml-2 flex items-center gap-2">
            <input type="radio" id="{{ 'type-'.$type }}" wire:model="selection" value="{{ $type }}">

            <label for="{{ 'type-'.$type }}">{{ $type }}</label>
        </fieldset>
    @endforeach

    Selection : {{ $selection }}
</div>

When I click on a radio button, the $selection value doesn't change.

Why ?

It should change !

Thanks for your help.

V

0 likes
2 replies
tykus's avatar
tykus
Best Answer
Level 104

If you want it to be live then add the live modifier to wire:model

<input 
    type="radio" 
    id="{{ 'type-'.$type }}"
    wire:model.live="selection" 
    value="{{ $type }}"
>
2 likes
vincent15000's avatar

@tykus Oh yes that's is, furthermore I knew it ... just a moment that I haven't coded with Livewire.

Please or to participate in this conversation.