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

asheek_mohammed's avatar

Livewire : form radio button value not passing to the component

I am learning livewire. I am building a quiz web app where each question shows after another.

In my component

			public $selectedOption ;
			
			public function nextQuestion()
    		{
                   dd($this->selectedOption);
        			if ($this->currentQuestionIndex < $this->allQuestions->count() - 1) {
                       $this->currentQuestionIndex ++;
                   }
            }
			

no matter what i do. i am not getting any data to selectOption.

Thanks in advance

0 likes
6 replies
MouteeSabouni's avatar

The issue you're encountering is because the x-data variable selectedOptionId is separate from Livewire’s $selectedOption property, meaning they are not connected. When you click an option, Alpine's selectedOptionId is being set, but it’s not reflected in Livewire's $selectedOption.

Try the following instead:

asheek_mohammed's avatar

@MouteeSabouni i forget to remove selectedOptionId. i am not using that anymore.

wire:model.defer="selectedOption"

i used this but still selectedOption is coming as null

MouteeSabouni's avatar

@asheek_mohammed Try using x-model="$wire.selectedOption". It could be an issue related to the difference in loading between Livewire and Alpine.

1 like
bilalbasheer's avatar
Level 1

x-model="$wire.selectedOption"

try this.

Issue might be with loading. Livewire sets up its event listeners when the page loads but alpine only after page loads.

so when using x-model="$wire.selectedOption" alpine handles creation and data binding

1 like

Please or to participate in this conversation.