Is there a way to trigger a RelationManager "create" action from a Widget action ?

On my Mission edit page, I have a table widget that list Users according to certain criteria. I created a button for each row that allow to create a Proposal to the User for the current Mission. The "create a Proposal" modal is already available in the "ProposalRelationManager" above. I was wondering if I can trigger the "ProposalRelationManager" create action instead of duplicate code in my Widget ?
No description
3 Replies
LeandroFerreira
LeandroFerreira10mo ago
add in the relation manager
#[On('openPropositionAction')]
public function openPropositionAction()
{
$this->mountTableAction('create');
}
#[On('openPropositionAction')]
public function openPropositionAction()
{
$this->mountTableAction('create');
}
dispatch it via action
Action::make('myAction')
->dispatch('openPropositionAction')
Action::make('myAction')
->dispatch('openPropositionAction')
Benjamin
BenjaminOP10mo ago
Thanks a lot @Leandro Ferreira ! And do you know howI can pass data to the form, to prefill it ? Like ->dispatch('openPropositionAction', ['user_id' => 15]) and then fill my Forms\Components\Select::make('user_id') in my create form ?
LeandroFerreira
LeandroFerreira10mo ago
hum, I don't know you can use fillForm or mountUsing to fill the data I guess https://filamentphp.com/docs/3.x/actions/modals#filling-the-form-with-existing-data
Want results from more Discord servers?
Add your server