Is it possible to display a resource create form within a table header Bulk action.

I need to associate multiple resources with another new resource. For this I have a bulk action in a table that opens up a modal and I can add a form in that action. But I don't know if there is a way to instead of adding the form on the action I can add an already existing create resource form. I could load the resource form with CreatePage::form(). But that doesn't seem to keep the original resource on the form and instead uses the resource from the table.
Solution:
Move your document form into the model. Make a static function called getForm() and return array. In your document resources call the getForm()...
Jump to solution
5 Replies
einnlleinhatt_
einnlleinhatt_8mo ago
If I understand correctly, you have resources A and inside there is a form A and you have resources B but with the click button action it will open the modal and inside the modal it has form A ?
Jean Roumeau
Jean Roumeau8mo ago
To be more precise. I have a resource "Media" where I store multiple files. On the table view of this resource I want to select multiple records (Bulk action) and add a button to classify this files under a "Document" resource. So when I click the bulk action "Classify" with the selected "Media" records, I want to open a modal with the form of the "Document" resource. Currently I'm adding the form directly on the Bulk Action definition, but I want to use the already existing "Document" form instead of handling two identical forms.
Solution
einnlleinhatt_
einnlleinhatt_8mo ago
Move your document form into the model. Make a static function called getForm() and return array. In your document resources call the getForm()
einnlleinhatt_
einnlleinhatt_8mo ago
return $form
->schema(Model::getForm())
return $form
->schema(Model::getForm())
Inside model
public static function getForm(): array
{
return [
Group::make()->columns(2)->schema([
TextInput::make('name')
->required()->maxLength(255),
TextInput::make('email')
->email()->required()->maxLength(255),
])
];
}
Inside model
public static function getForm(): array
{
return [
Group::make()->columns(2)->schema([
TextInput::make('name')
->required()->maxLength(255),
TextInput::make('email')
->email()->required()->maxLength(255),
])
];
}
Jean Roumeau
Jean Roumeau8mo ago
This worked great. Thanks.