Hello
I try to send Carbon date string during mount to livewire parent component.
I have child component @livewire('counting.action-date').
during mount, it will pickup carbon:now()
and should emitUp to parant component.
public function mount()
{
$this->actionDate = Carbon::now()
// ->format('Y-m-d');
->toDateString();
$this->sendActionDate($this->actionDate);
}
public function sendActionDate($value)
{
$this->validate([
'actionDate' => 'required',
]);
$this->actionDate = $value;
$this->emitUp('savedDateUpdated', $this->actionDate);
}
** if I dump $this->emitUp('savedDateUpdated', $this->actionDate);
- it says null // app\Http\Livewire\Counting\ActionDate.php:29
** if I dump $this->actionDate or $value
- "2023-01-10" // app\Http\Livewire\Counting\ActionDate.php:29
Parent component:
public function savedDateUpdated($value)
{
$this->saveDate = $value;
}
- if I delete exist value from input element and
add date manually, it will send new value to parent.
** input element is blade component:
<x-date-input wire:model="actionDate">
<x-slot name="type">
date
</x-slot>
<x-slot name="name">
action_date
</x-slot>
<x-slot name="placeholder">
Laskun Kirjauspäivä
</x-slot>
I am stuck, how fix this ???
thanks advice ....Mika.