modal didn`t show

when click on button still loading and then stop withou show modal
No description
No description
8 Replies
mohamedali5738
mohamedali57386mo ago
any solution ?
Tobias Platen
Tobias Platen6mo ago
Maybe because ->action() is missing?
mohamedali5738
mohamedali57386mo ago
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();" ?
Tobias Platen
Tobias Platen6mo ago
I dont know your buisniss logic, but you need the action()-Method to define the action itself.
return Action::make('Buy Now')
->form([
TextInput::make('qty')
->label('Quantity')
->numeric(),
])->action(function (array $data): void {
$this->product->buy($data['qty'], Auth::user()->id);
});
return Action::make('Buy Now')
->form([
TextInput::make('qty')
->label('Quantity')
->numeric(),
])->action(function (array $data): void {
$this->product->buy($data['qty'], Auth::user()->id);
});
mohamedali5738
mohamedali57386mo ago
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 😢
Tobias Platen
Tobias Platen6mo ago
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.
mohamedali5738
mohamedali57386mo ago
" 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
awcodes
awcodes6mo ago
Action::make(‘create’)->label(‘Buy Now’)