My code isn’t really that different:
Model:
\App\Bill
Livewire Component
CreateInvoice.php
namespace App\Http\Livewire;
use App\Rules\AlphaLatinUmlaut;
use App\Rules\Iban;
use Livewire\Component;
use App\Bill;
class CreateInvoice extends Component
{
public Bill $bill;
public function rules()
{
//validation rules
}
public function mount()
{
$this->bill = new Bill(); // i tried both variants. with this and without this.
}
public function updated($propertyName)
{
$this->validateOnly($propertyName);
}
create-invoice.blade.php
<form wire:submit.prevent="save">
<input wire:model="bill.Name" type="text" class="....">
</form
As soon as i want to enter something into the field i get the error.
Typed property App\Http\Livewire\CreateInvoice::$bill must not be accessed before initialization
The point is: Its the form field to add a record to the database. Its not yet persisted.
How does laravel keep track of the component properties while its on screen.
public $name = "John";
Where is the value of $name stored when it changes between (xhr) requests. In the session?
Tobi