Hi!
I'm using package https://github.com/wire-elements/modal to open a modal.
I have a problem. When I'm open a modal form is not have data i.e user name.
In Log file I see that in mount method object is correct.
user-edit.blade.php
<div>
<div class="max-w-7xl mx-auto sm:px-6 lg:px-8">
<div class="bg-white overflow-hidden shadow-sm sm:rounded-lg">
<div class="p-6 bg-white border-b border-gray-200">
<form wire:submit.prevent="update">
@csrf
<x-input-label for="name" :value="__('Name')"/>
<input type="text" name="name" wire:model.defer="user.name">
</form>
</div>
</div>
</div>
</div>
In Livewire class I have:
EditUser.php
<?php
namespace App\Http\Livewire\User;
use App\Models\Role;
use App\Models\User;
use Illuminate\Contracts\Foundation\Application;
use Illuminate\Contracts\View\Factory;
use Illuminate\Contracts\View\View;
use Illuminate\Support\Facades\Log;
use LivewireUI\Modal\ModalComponent;
class UserEdit extends ModalComponent
{
public User | int $user;
public function mount(User $user)
{
$this->user = $user;
}
public function render(): Factory|View|Application
{
Log::debug($this->user);
$roles = Role::all();
return view('livewire.user.user-edit', ['roles' => $roles]);
}
}
Log file:
[2022-11-04 22:33:45] local.DEBUG: {"id":4,"name":"lee","full_name":"Dr. Declan O'Reilly V","gender":"male","age":47,"height":129,"current_weight":86,"email":"[email protected]","email_verified_at":"2022-11-01T19:59:49.000000Z","created_at":"2022-11-01T19:59:49.000000Z","updated_at":"2022-11-01T19:59:49.000000Z"}