y_e_v_h_e_n_i_i
y_e_v_h_e_n_i_i
FFilament
Created by y_e_v_h_e_n_i_i on 10/1/2024 in #❓┊help
Using tabs not repeater for dynamic form
i have multiple database tables with following structure
 articles
 - id
 - author_id - created_at
 - updated_at 
article_localizations
 - id - article_id - locale - title
- body - created_at - updated_at and i have this code for rendering fields for each localization in separate tab.
Forms\Components\Tabs::make('localizations_tabs')
->tabs(function () {
$tabs = [];
$localizations = $this->record->localizations;

foreach ($localizations as $index => $localization) {
$tabs[] = Forms\Components\Tabs\Tab::make($localization->locale)
->schema([
Forms\Components\TextInput::make("localizations.{$localization->id}.locale")
->label('Locale')
->default($localization->locale)
->required(),
Forms\Components\TextInput::make("localizations.{$localization->id}.title")
->label('Title')
->default($localization->title)
->required(),
Forms\Components\RichEditor::make("localizations.{$localization->id}.body")
->label('Body')
->default($localization->body)
->required(),
]);
return $tabs;
}
})
->columnSpanFull(),
Forms\Components\Tabs::make('localizations_tabs')
->tabs(function () {
$tabs = [];
$localizations = $this->record->localizations;

foreach ($localizations as $index => $localization) {
$tabs[] = Forms\Components\Tabs\Tab::make($localization->locale)
->schema([
Forms\Components\TextInput::make("localizations.{$localization->id}.locale")
->label('Locale')
->default($localization->locale)
->required(),
Forms\Components\TextInput::make("localizations.{$localization->id}.title")
->label('Title')
->default($localization->title)
->required(),
Forms\Components\RichEditor::make("localizations.{$localization->id}.body")
->label('Body')
->default($localization->body)
->required(),
]);
return $tabs;
}
})
->columnSpanFull(),
problem is that data not setting in fields. please help to figure out what is wrong. when i use repeater everything works fine, but i need tabs for my implementation and i don't know how to use them with repeater. thank you for help
8 replies