passing data between forms
I have two forms, headerData and footerData. Is it possible to pass data from header to footer? Or what would be the same, get data from a field in header in footer?
4 Replies
Are they different livewire components?
no sir, within the same component
$this->headerData ?
field in headerData:
Placeholder::make('total')
->columnSpan(2)
->hiddenLabel()
->live()
->content(fn () => new HtmlString('
<div style="text-align: right;">
<div style="font-size: 20px; color: #a9a9a9;">Subtotal</div>
<div style="font-size: 35px; font-weight: bold;">' . $this->cartTotal . '</div>
</div>
'))
->afterStateUpdated(function (Set $set) {
//$set('./total', $this->cartTotal);
$this->footerData['subtotal'] = $this->cartTotal;
}),
Once the process is finished, the user presses "confirm" and a "footerForm" modal is displayed, where I have the input "subtotal":
public function footerForm(Form $form): Form
{
return $form
->model(Sale::class)
->statePath('footerData')
->schema([
TextInput::make('subtotal')
->columnSpanFull()
->live()
->disabled()
->dehydrated(true),
This input must contain the same value as the placerholder "total"
SOLVED updated field in footerForm with:
->action(function () {
$this->openModal();
$this->footerData['subtotal'] = $this->cartTotal;
}),