action with form with livewire component inside

hello everyone, i added an action inside my livewire component, this is the code:
public function checkModal(): Action
{
return Action::make('transaction')
->action(function (array $arguments, array $data): void {
$item_id = $this->item->id;
//make something
})
->fillForm(fn ($record, $arguments): array => [
'option_id' => $arguments['option_id'],
'amount' => 0,
])
->form([
Select::make('option_id')
->prefix(__('item::article.select-option'))
->hiddenLabel()
->options($this->option_opts)
->required()
->reactive()
->afterStateUpdated(function () {
$this->dispatch('update-current-prices');
}),
TextInput::make('amount')
->hiddenLabel()
->numeric()
->rules('gt:0')
->reactive()
->afterStateUpdated(function () {
$this->dispatch('update-current-stock');
}),
Livewire::make(TransactionInformation::class, fn (Get $get) => [
'amount' => $get('amount'),
'item_uuid' => $this->item_uuid,
'option_id' => $get('option_id'),
'option_options' => array_keys($this->option_opts),
]),
])

}
public function checkModal(): Action
{
return Action::make('transaction')
->action(function (array $arguments, array $data): void {
$item_id = $this->item->id;
//make something
})
->fillForm(fn ($record, $arguments): array => [
'option_id' => $arguments['option_id'],
'amount' => 0,
])
->form([
Select::make('option_id')
->prefix(__('item::article.select-option'))
->hiddenLabel()
->options($this->option_opts)
->required()
->reactive()
->afterStateUpdated(function () {
$this->dispatch('update-current-prices');
}),
TextInput::make('amount')
->hiddenLabel()
->numeric()
->rules('gt:0')
->reactive()
->afterStateUpdated(function () {
$this->dispatch('update-current-stock');
}),
Livewire::make(TransactionInformation::class, fn (Get $get) => [
'amount' => $get('amount'),
'item_uuid' => $this->item_uuid,
'option_id' => $get('option_id'),
'option_options' => array_keys($this->option_opts),
]),
])

}
as you can see, inside the action form I use another livewire component TransactionInformation that calculates and displays a result, which I would then like to reuse inside the action business logic, basically inside ->action(function (array $arguments, array $data). I thought I would find something inside $arguments or $data, but I don't see anything. how do I retrieve a TransactionInformation property? where am I going wrong? I hope I explained my problem well, thanks in advance
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server