Component & Field changes

Refactor Form attributes, move from mount() to formAttr()

To protect form attributes from being exposed to frontend, they are now loaded as a Livewire computed property.

Before

public function mount(User $user)
{
    $this->fill([ //you might have used $this->fill([])...
        'wrapWithView' => false,
        'inline' => false,
        'showDelete' => false,
    ]);
    
    $this->formTitle = 'Edit User'; //...or, you set the form attributes separately
    
    $this->mount_form($user);
}

Now

public function mount(User $user)
{   
    $this->mount_form($user);
}

public function formAttr(): array
{
    return [
        'formTitle' => 'Edit User',
        'wrapWithView' => false,
        'inline' => false,
        'showDelete' => false,
    ];
}

Component methods changed to protected

You might get errors from functions that has been changed from public to protected.

Methods that has been changed from public to protected

Comment

onCreateModel

onUpdateModel

onDeleteModel

See special note on this page

fields

saveFoo

beforeFormProperties

afterFormProperties

delete() and onDeleteModel() security risk!

The delete() method is public, which means that it can be called from frontend. You should probably override it to add your desired access control. That is what the onDeleteModel() hook is for. Please override it in your component. (This is nothing new, I just want to emphasize the importance of this method.)

Search and replace:

Field type

Search

Replace with

Comment

Input

Number Color DateInput TimeInput DateTimeLocal Week Month Email Number Password Tel Url

->class(...)

->wrapperClass(...)

class() still exists, but is applied to the input instead of the outmost div.

Input type hidden

(Honeypot)

->class('nosy')

->wrapperClass('nosy')

See previous comment

Deprecated fields or field methods

These methods are still kept in the code, for legacy reasons.

Deprecated

Replace with

Example/Comment

noDefer()

deferEntangle(false)

Use any of the methods,

read more: Alpine page

SpatieTags

Tags or TagsSearch

keyAsAttribute

validationAttr(string)

Changed defaults

Field

Comment

Input, type number

max changed from 100 to infinite

$onKeyDownEnter

Default = "saveAndStay" instead of null.

Changed field methods

Method

Comment

includeExternalScripts(bool $state = true)

Added option to pass true/false

New field methods/attributes

Field

Method/comment

Input

icon(string $name, ?string $class) sfxIcon(string $name, ?string $class)

Add classes to Blade UI Kit icons

Heading

Panel

Tabs

icon(string $name, ?string $class)

Add classes to Blade UI Kit icons

All Fields

wrapperClass(string $classes)

Applied to field component, root div

All Fields

errorClass(string $classes, bool $append = true)

Append to, or replace, default field error class.

All Fields

wire(...)

It is optional to type wire:model, the modifier is enough. Exampel: wire('debounce.750ms')

Most Fields

disabled(bool $state = true)

Fixed

Method

Comment

class(

string $classes,

$append = true

)

$append was always true. Now it either appends to default input class or replaces it.

Validation

The get_rules() method has changed to follow Livewire standards. If you have overridden it in your components. Please se the Validation page for changes.

Last updated