Summer Sale! All accounts are 50% off this week.

an.leclerc's avatar

Live updated with form

Hi,

In my template I have a select field :

<flux:field>
    <flux:label badge="Required">Statut précédent</flux:label>
    <flux:select wire:model.live="form.type_dossier_status_id" variant="listbox" placeholder="Choisir le statut précédent...">
        @foreach ($this->statuses() as $item)
            <flux:select.option value="{{ $item->id }}">{{ $item->label }}</flux:select.option>
        @endforeach                    
    </flux:select>
</flux:field>

In my component, this field is related to a form :

...
class DossierStatusTypeAdmin extends Component
{
    ...
    public TypeDossierStatusForm $form;
    ...
}
...
class TypeDossierStatusForm extends Form
{
    ...
    public ?string $type_dossier_status_id = null;
    ...
}

But live update doesn't work. If I put the variable in the component and change input in blade wire:model.live="type_dossier_status_id" it works

Any idea ?

0 likes
4 replies
valentin_vranic's avatar

What does it mean it doesn't works? Doesn't preserve the value when you submit? Or doesn't trigger it's updated lifecycle method?

an.leclerc's avatar

It doesn't trigger updated lifecycle method

an.leclerc's avatar

I did it with wire:change on select and it works

valentin_vranic's avatar

@an.leclerc Glad that you've solved it. Only a quick reminder, since you're using forms, and .live modifier, the change event can be caught like this

in case that you use camel cased properties: typeDossierStatusId

public function updatedFormTypeDossierStatusId(): void {}

Please or to participate in this conversation.