Relationship table on modal? or NEW action on table action page?

I managed to find out that if I create a Resource with -- generate --simple and add a RelationManager to it I will not see the Relation div. After some struggling/searching/reading posts/searching tutorials... I recreated the Resource with --generate and registered the relation manager to it and I see the table with all functions. If I comment the
'edit' => Pages\EditAgenti::route('/{record}/edit'),
'edit' => Pages\EditAgenti::route('/{record}/edit'),
the edit will move to a modal and I do not see the table anymore. I need an option to add the RelationManager panel on the modal, or even better I want a custom action button on the view page that will open the create form and save to the relation's Model. somethink like:
Action::make("add-new-to-relation's-model")
Action::make("add-new-to-relation's-model")
that will open a modal where I have what I configure in the relation's form.
Solution:
``` Action::make('adauga') ->label('Add container') ->icon('heroicon-o-folder-plus') ->form([...
Jump to solution
13 Replies
Dennis Koch
Dennis Koch5mo ago
I need an option to add the RelationManager panel on the modal,
That's not possible. Currently you can't put tables inside forms.
or even better I want a custom action button on the view page that will open the create form and save to the relation's Model.
Okay. Sounds like a normal action for me? Where are you stuck?
yangsystem
yangsystemOP5mo ago
you have on the simple page below the edit/view the table with the action buttons for the relation. I will like eigter to import the same table to the modal or just to have a button for the action to create a record for that relation
yangsystem
yangsystemOP5mo ago
modal
desired functionality
yangsystem
yangsystemOP5mo ago
normal page
yangsystem
yangsystemOP5mo ago
also there is a type there "I need an option to add the RelationManager panel to the modal, when I click edit/view" I do not know how to add the action on-click to the green colored "New contracte" near blue "Edit" on the main page that will open a modal with the form that I create in the relationmanager.
Dennis Koch
Dennis Koch5mo ago
Yes I know. And I just told you that it’s not possible in a View/Edit modal.
yangsystem
yangsystemOP5mo ago
ok. please point me in the right direction on how to create the action to create a new record
Dennis Koch
Dennis Koch5mo ago
I don’t understand Please check the action docs. It’s an Action with a form and you need to save the data. Happy to help if you get stuck there.
yangsystem
yangsystemOP5mo ago
Action included in the table docs or action on main docs?
Dennis Koch
Dennis Koch5mo ago
They all follow the same concepts. If you want to use it in the table check the tables docs.
yangsystem
yangsystemOP5mo ago
Will try and come back with my problem or with a 10Q it work's like this
Solution
yangsystem
yangsystem5mo ago
Action::make('adauga')
->label('Add container')
->icon('heroicon-o-folder-plus')
->form([
Forms\Components\TextInput::make('contracte_id')
->default('1'),
Forms\Components\TextInput::make('container_tip')
->required()
->maxLength(255),
])
->action(function (array $data, Containere $container): void {
$container->contracte_id = $data['contracte_id'];
$container->container_tip = $data['container_tip'];
$container->save();
}),
Action::make('adauga')
->label('Add container')
->icon('heroicon-o-folder-plus')
->form([
Forms\Components\TextInput::make('contracte_id')
->default('1'),
Forms\Components\TextInput::make('container_tip')
->required()
->maxLength(255),
])
->action(function (array $data, Containere $container): void {
$container->contracte_id = $data['contracte_id'];
$container->container_tip = $data['container_tip'];
$container->save();
}),
yangsystem
yangsystemOP5mo ago
10q for support another question should I do the validation on the action method with classic laravel syntax or should I do the filament validation?
Want results from more Discord servers?
Add your server