I need to access $record on Table Action form

I have the following. In relation to the invoiceReadyValue form field. this is a value already stored on the record but I want the ability to edit this field and then save it. I may have a few forms for different actions on the table row. I cannot work out how to prefil the value into the form entry though, its blank but there is a value stored. Any ideas? Thanks all.
->actions([
ActionGroup::make([
Action::make('Toggle Supplier Order')
->requiresConfirmation()
->action(fn (docket $record) => $record->update(['docProgSupplierOrder'=> !$record->docProgSupplierOrder ])),
Action::make('Submit For Invoicing')
->accessSelectedRecords()
->form([
TextInput::make('invoiceReadyValue')->required(),
])
->action(function (array $data, docket $record): void {
$record->invoiceReadyValue = $data['invoiceReadyValue'];
$record->save();
Notification::make()
->title('Invoice Submitted')
->success()
->send();
})
])
->actions([
ActionGroup::make([
Action::make('Toggle Supplier Order')
->requiresConfirmation()
->action(fn (docket $record) => $record->update(['docProgSupplierOrder'=> !$record->docProgSupplierOrder ])),
Action::make('Submit For Invoicing')
->accessSelectedRecords()
->form([
TextInput::make('invoiceReadyValue')->required(),
])
->action(function (array $data, docket $record): void {
$record->invoiceReadyValue = $data['invoiceReadyValue'];
$record->save();
Notification::make()
->title('Invoice Submitted')
->success()
->send();
})
])
10 Replies
LeandroFerreira
LeandroFerreira4mo ago
->mountUsing(fn (Form $form, $record) => $form->fill($record->attributesToArray()))
->mountUsing(fn (Form $form, $record) => $form->fill($record->attributesToArray()))
David | Fortune Validator
thank you so much. That worked. May I ask where in the docs you found that?
David | Fortune Validator
thank you. Does this stop relationships from working correctly? I need a select dropdown that is part of a relationship between the Docket and another model
LeandroFerreira
LeandroFerreira4mo ago
this should work. What is the issue?
David | Fortune Validator
Data wasnt pulling into the component for the relationship. It may be user error though so I'll lkeep trying. I dont suppose you know how to use a multi level relationship on a Select? e.g Docket has an Estimate which has a Product Type. Relations are setup in models okay I can pull in lets say 'estimate','id' okay but how would I go a level deeper?
LeandroFerreira
LeandroFerreira4mo ago
What code are you trying to do?
David | Fortune Validator
Not by my pc at the moment. I think though perhaps I need a new relationship on my Docket to pass through the Estimste and onto ProductType. #p.s fairly new to relationships embarrassingly Okay so I’m a little stumped. I have the following Docket Model ( contains an estimate_id) Estimate Model ( contains an product_id) Product Model On my Docket model based form. I want to use a Select component to access the product list and assigned product to the estimate. So as you can see it’s two levels deep. From the select relationship documentation I can only see the ability to go one level deep. Such as access estimates_id’s from Docket. As I’m typing this however. I’m seriously wondering if the product should be linked to the docket once a docket is created anyway.
awcodes
awcodes4mo ago
You might be able to do it with a HasManyThrough relationship.
David | Fortune Validator
Thought about that but it’s all one belongs to one. I’ve moved product id to the docket know. Which to be honest it should have been. Thank you
Want results from more Discord servers?
Add your server
More Posts
I want to put a button next to the delete button and direct it to the address in the path, how can II will put a button here and I want it to go to the link in the path of the clicked record in a new Class "Filament\Forms\Components\XXXX" not found on remote server. Dashboard and List are working.I might have overlooked something straightforward while deploying to a new remote server on DigitalOFileUpload imageEditor replace instead of adding v1, v2 to the fileHello, I am uploading images using FileUpload and I have added the imageEditor option and it works gConcat two form fields with multiple select relationshipHey ! In a resource file, i have this ```public static function form(Form $form): Form { File upload not returning url after uploadI created a form to send a message and attach files, the files upload, but the he data that comes bacopyable table column error on production vpsi already run npm install and build on my terminal and its fine error on console browser livewirlockout user after 3 failed logins for 10 minutes?how to do lockout user after 3 failed log ins for 10 minutes?BelongsToMany TextColumn first_name last_name searchableHello, How do I make the TextColumn searchable by first_name and last_name for a belongsToMany relaSet Panel (Has Authentication) to be accessed by the PublicHi there, Would it be possible to set the Panel publicly meaning the pages there can be accessed eveHalt modal action``` ->modalFooterActions([ Action::make('TakePayment') ->form([ ]), ])