Create Comment - where to inject parent ID?

I was able to get a view and edit to display comments related to orders, but the 'create' button(s) aren't working because it's not carrying over the order item id. I'm not sure where or how to interject that value. When I edit the order record, it shows the comments at the bottom with a create record (action) button. I was able to track this down to the relation manager actions by playing with the ->label() method. But clicking that button pops up a modal and I'm not sure how to make it aware of the order item id.
No description
2 Replies
treii28
treii28OP2mo ago
No description
treii28
treii28OP2mo ago
Also, I assume that modal pop-over should have form fields. I have a statoc form method defined in the OrderCommentResource and even pulled the schema array out to a static getSchema() method, but it doesn't seem to be getting picked up by the model. OK, I was able to figure out the form is defined in the relation manager (and presumably i could call my getSchema from the resource manager if desired) But still need to know how to get the order_id in that context, and I will also need to get the user id. (I tried using Filament::auth()->id but that din't seem to fill in any value) kk with the help of github copilot, I figured out that I could set a ->default() in the relationmanager: Forms\Components\TextInput::make('order_item_id') ->default(function () { $ownerRecord = $this->getOwnerRecord(); return $ownerRecord ? $ownerRecord->id : null; }) ->numeric(),
Want results from more Discord servers?
Add your server