8 Replies
any solution ?
Maybe because ->action() is missing?
mean this " return Action::make('Buy Now')
->form([
TextInput::make('qty')
->label('Quantity')
->numeric(),
Hidden::make('product_id')->default($this->product->id)->required(),
Hidden::make('user_id')->default(Auth::user()->id)->required(),
])->action();"
?
I dont know your buisniss logic, but you need the action()-Method to define the action itself.
yes i but now " return Action::make('Buy Now')
->form([
TextInput::make('qty')
->numeric(),
Hidden::make('product_id')->default($this->product->id)->required(),
Hidden::make('user_id')->default(Auth::user()->id)->required()
])
->action(function (array $data, OrderStock $record): void {
$record->product_id = $data['product_id'];
$record->user_id = $data['user_id'];
$record->qty = $data['qty'];
$record->save();
});"
but form modal doesnot show 😢
Then I think your installation is not complete. If you have only used filament as a panel, this is not enough to use actions directly in a Livewire component.
You should remove the hidden fields from your form. For example, the user could manipulate the UserID and place an order for someone else.
" return Action::make('Buy Now')
->form([
TextInput::make('qty')->numeric(),
])
->action(function (array $data, OrderStock $record): void {
$record->product_id = $this->product->id;
$record->user_id = $data['user_id'];
$record->qty = Auth::user()->id;
$record->save();
});"
still form not show
Action::make(‘create’)->label(‘Buy Now’)