wire:model
Overview
You can use wire:model in your templates to bind to data properties with form inputs.
When the user submits the form, the server receives a request with the updated data property values from the inputs. An email is sent, and the template is re-rendered with the updated values.
When using wire:model, Livewire will only send a network request when an action is performed, like with wire:click or wire:submit. However, you may want to update the server more frequently for things like real-time validation. In those instances, use wire:model.live.
Live Updating
You can use wire:model.live to send property updates to the server as a user types.
By default, Livewire adds a 150-millisecond debounce to server updates. If the user is continually typing, Livewire will wait until the user stops typing for 150 milliseconds before sending a request.
You can customize the debounce using wire:model.live.debounce.Xms.
Modifiers
Livewire provides various modifiers to control when server requests are sent.
Below are all the available modifiers:
.live
Send updates as user types
.blur
Only send updates on blur event
.change
Only send updates on the change event
.lazy
Alias for .change
.debounce.Xms
Debounce sending updates for X milliseconds
.throttle.Xms
Throttle network request updates by X milliseconds
.number
Cast text input to an integer on the server
.boolean
Cast text input to a boolean on the server
.fill
Use the initial value the "value" HTML attribute provides during page load.
Input Fields
Below shows how to bind various input fields with your data properties.
Text inputs
Textarea inputs
If the content data property is initialized with a string, Livewire will fill the textarea with its value. Don't do this.
Single Checkbox
If the receiveUpdates data property is false, the checkbox will be unchecked. If true, it will be checked.
Multiple Checkboxes
Checkboxes with multiple inputs are stored as an array.
Radio buttons
Select dropdowns
Livewire automatically adds a selected attribute to the option that matches the data property value.
You can dynamically populate these with values.
Dependent select dropdowns
If you have a dropdown that is dependent on the value of another dropdown and needs to update, you can use wire:key to ensure it updates.
Multi-select dropdowns
Last updated