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

mikethelad's avatar

wire:model

I have wire:model working for

<input wire:model="additionalData.testcompletedby" type="text" required="" class="text-input-box" name="testcompletedby">

<input type="radio" wire:model="additionalData.soundersHeard" value="yes"> Yes

But will not work (store the data) for

            <x-form.yes-no :parts="[
                    'model' => 'additionalData.soundersheard',
                    'label' => 'Sounders heard',
                    'span' => '',
                    'na' => '',
                    'conditionalParent' => '',
                ]"
            ></x-form.yes-no>

Any suggestions on what to look for?

0 likes
7 replies
jaseofspades88's avatar

If you're using Livewire 3, then you'll probably need to add wire:model.live="property".

mikethelad's avatar

Like this (as still the same)

            <x-form.yes-no wire:model.live="property" :parts="[
                    'model' => 'additionalData.soundersheard',
                    'label' => 'Sounders heard',
                    'span' => '',
                    'na' => '',
                    'conditionalParent' => '',
                ]"
            ></x-form.yes-no>
shawnyv's avatar

In the first example, it doesn't look like you actually had wire:model anywhere. In the second, you were trying to bind it to something called "property".

In both cases, you're trying to use wire:model on your custom "x-form.yes-no" component, which I"m pretty sure won't work.

You need to attach the wire:model directly to an input (e.g. , , , etc).

mikethelad's avatar

I have also tried and does not work

            <x-form.yes-no :parts="[
                    'wire:model' => 'additionalData.soundersheard',
                    'label' => 'Sounders heard',
                    'span' => '',
                    'na' => '',
                    'conditionalParent' => '',
                ]"
            ></x-form.yes-no>
mikethelad's avatar

This is my yes no component


   @if($label)
       <label for="{{ $model }}" class="form-label">{{ $label }}</label>
   @endif

   <div class="flex mt-2">
       @foreach($options as $option)
           <label
               x-on:click="[activeOption = '{{ $option }}', @if( $conditionalParent ) $wire.updateConditionalField(['{{ $model }}', {{ $model }}.value]) @endif]"
               class="standard-button w-20 mr-4 text-blue"
               :class="['{{ $option }}' == 'Yes' ? 'bg-lime-400' : '{{ $option }}' == 'No' ? 'bg-red-400' : 'bg-gray-400',  activeOption == '{{ $option }}' ? '' : 'opacity-40' ]"
           >
               {{ $option }} 
               <input class="hidden" type="radio" name="{{ $model }}" wire:model.defer="{{ $model }}" value="{{ $option }}"/>
           </label>
       @endforeach
   </div>
</div>
Snapey's avatar

Your component is wire model to the :model attribute

'model' => 'additionalData.soundersheard',

However, I don't see how your component can read from a parts array.

Suggest you consult the documentation for the component

Please or to participate in this conversation.