F
Filament8mo ago
Abi

Updating Standalone Action's modal description based on the argument passed to the form

I have a standalone action that launches a modal. I want to update the modal description based on the argument passed to the Form?
Action::make('addToCart')
->label('ADD PLAYERS TO CART')
->modalDescription(new HtmlString('Some Description goes here.'))
->modalWidth('2xl')
->modalSubmitActionLabel('Add Player to Cart')
->modalFooterActionsAlignment('end')
->form(function ($arguments) {
// Update the Modal Description from here.
})
Action::make('addToCart')
->label('ADD PLAYERS TO CART')
->modalDescription(new HtmlString('Some Description goes here.'))
->modalWidth('2xl')
->modalSubmitActionLabel('Add Player to Cart')
->modalFooterActionsAlignment('end')
->form(function ($arguments) {
// Update the Modal Description from here.
})
5 Replies
toeknee
toeknee8mo ago
You can't really do that, you could have the description load a state value? defaulting to Some Description. And selecting a value is live which would cause the modal to refresh. Or you can use the placeholder field instead of description and set the value that way?
Abi
AbiOP8mo ago
so, there is no way to access the action object inside the form function ?
toeknee
toeknee8mo ago
Not as far as I am aware. You could try passing in $action within the function, but it hasn't been initiated yet so I double it.
Abi
AbiOP8mo ago
i do have the instance of the $action on the form closure, but setting the modalDescription doesn't take effect, not sure if I need to do something to re-render
toeknee
toeknee8mo ago
Did you set the form field as live?
Want results from more Discord servers?
Add your server