Multiple forms in tabs with relation manager

I have a Relation Manager with the following form:
public function form(Form $form): Form
{
return $form
->schema(
MediaCompanyForm::schema()
);
}
public function form(Form $form): Form
{
return $form
->schema(
MediaCompanyForm::schema()
);
}
For each tool that exists, I show a tab with different forms. I would like each form to have a submit. Is there a way to do this or should I change the approach?
public static function schema(array $options = []): array
{
return [
TextInput::make('name')->label('Nombre')->required(),
Tabs::make('configTools')
->hidden(!Tool::count())
->hiddenOn('create')
->loadStateFromRelationshipsUsing(function ($record, $set) {
if ($record) {
foreach ($record->configTools as $configTool) {
if($configTool->current_config) {
$set('configTools.' . $configTool->tool_id, $configTool->toArray());
}
}
}
})
->schema(self::getTabs())->columnSpanFull(),
];
}

private static function getTabs(): array
{
$tabs = [];

$tools = Tool::all();

foreach ($tools as $tool) {
$name = $tool->name;
$slug = str($name)->slug()->toString();

$tabs[$slug] = Tab::make($name)
->schema(ConfigToolForm::schema(options: ['tool_id' => $tool->id, 'includePrefixColumn' => true]))
->columns(2);
}

return $tabs;
}
public static function schema(array $options = []): array
{
return [
TextInput::make('name')->label('Nombre')->required(),
Tabs::make('configTools')
->hidden(!Tool::count())
->hiddenOn('create')
->loadStateFromRelationshipsUsing(function ($record, $set) {
if ($record) {
foreach ($record->configTools as $configTool) {
if($configTool->current_config) {
$set('configTools.' . $configTool->tool_id, $configTool->toArray());
}
}
}
})
->schema(self::getTabs())->columnSpanFull(),
];
}

private static function getTabs(): array
{
$tabs = [];

$tools = Tool::all();

foreach ($tools as $tool) {
$name = $tool->name;
$slug = str($name)->slug()->toString();

$tabs[$slug] = Tab::make($name)
->schema(ConfigToolForm::schema(options: ['tool_id' => $tool->id, 'includePrefixColumn' => true]))
->columns(2);
}

return $tabs;
}
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server