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

Houdinux's avatar

Livewire Input Field Not Initializing with Data

Hello everyone,

I've been working on a Livewire component for configuring system settings in a Laravel application and encountered an issue where the input fields were not displaying their initial values, despite being properly set up in the component's state.

In my Livewire component, I was setting the initial values for anniversary_code_validity and newsletter_code_validity in the mount() method from my model Configuration. Despite the values being properly assigned and confirmed through logging / dd / dump, the input fields in my form were rendered without any values.

Code Example:

public function mount()
{
    $config = Configuration::first();
    $this->anniversary_code_validity = $config->anniversary_code_validity;
    $this->newsletter_code_validity = $config->newsletter_code_validity;
}

Blade Template:

<input type="number" class="form-control" id="anniversary_code_validity"
    wire:model="anniversary_code_validity">
@dump('anniversary_code_validity'); // this shows the correct value on my view

If i add the value attribute to the input fields in the Blade template:

<input type="number" class="form-control" id="anniversary_code_validity"
    wire:model="anniversary_code_validity" value="{{ $anniversary_code_validity }}">

It works, but it doesn't feel right.

Is there a more "Livewire" way to ensure the input fields are initialized correctly without manually setting the value attribute? Could this issue be related to a potential bug in Livewire, or is it more likely a conflict or mistake in my setup?

Livewire version : 2.11

0 likes
1 reply
Houdinux's avatar
Houdinux
OP
Best Answer
Level 1

Ok i fixed it, I had double the : @extends('layouts.master', ['title' => 'title'])

@section('workspace')

In the livewire folder and in the view folder.

Please or to participate in this conversation.