F
Filamentβ€’17mo ago
Mark Chaney

Preview action button on modal

If i have a form within a modal and ive added an extraModalFooterActions, with:
->extraModalFooterActions(fn(Action $action) => [
$this->previewTermsAction($action),
])
->extraModalFooterActions(fn(Action $action) => [
$this->previewTermsAction($action),
])
and then
private function previewTermsAction($action)
{
return $action
->label('Preview')
->modalHeading('Preview')
->form(function ($form) {
$record = $form->getFormData();
ray($record);
return TermsAndCondition::getAcceptForm($record, preview: true);
})
->slideOver();
}
private function previewTermsAction($action)
{
return $action
->label('Preview')
->modalHeading('Preview')
->form(function ($form) {
$record = $form->getFormData();
ray($record);
return TermsAndCondition::getAcceptForm($record, preview: true);
})
->slideOver();
}
, how should i go about getting whatever data is currently in the form (regardless if fields are disabled or not) so that i can send them to another form? (Initial form is for creating a few parameters and the other one is the client facing form that uses that data). I know Im not going about it correctly as i dont even see the data in $form when its a new record being created and it hasnt been saved yet.
3 Replies
Patrick Boivin
Patrick Boivinβ€’17mo ago
The context here with the nested modals is quite different from what I'm doing for page previews in #peek, but in your Preview action's form(), I think you can access the unsaved data from the Livewire component, try:
->form(function ($livewire) {
dd($livewire->mountedActionsData);
})
->form(function ($livewire) {
dd($livewire->mountedActionsData);
})
Mark Chaney
Mark ChaneyOPβ€’17mo ago
hmm, i thought i had looked at livewire already, but it appears that its under mountedTableActionsData. I am using a table header action to launch the original modal, its just a regular action from the modal launching the new one. Regardlress, i really appreciate it. Will see what i can do from there. Thanks!
Patrick Boivin
Patrick Boivinβ€’17mo ago
Makes sense, I did a quick test on a page with a regular action, that's why I found the other property πŸ˜„
Want results from more Discord servers?
Add your server