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
protected function getLocalizationTabs(): array
{
$localizations = $this->record->localizations;

$tabs = [];
$data = [];

foreach ($localizations as $localization) {
$data[$localization->id]['body'] = $localization->body;
$data[$localization->id]['title'] = $localization->title;
$data[$localization->id]['locale'] = $localization->locale;
$tabs[] = Forms\Components\Tabs\Tab::make($localization->locale ?? 'New Localization')
->schema([
Forms\Components\TextInput::make("localizations.$localization->id.locale")
->label('Localization')
->required(),
Forms\Components\TextInput::make("localizations.$localization->id.title")
->label('Title')
->required(),
Forms\Components\Textarea::make("localizations.$localization->id.body")
->label('Body')
->required(),
]);
}

$this->data['localizations'] = $data;

$tabs[] = Forms\Components\Tabs\Tab::make('New Localization')
->schema([
Forms\Components\TextInput::make("new_localization.locale")
->label('Localization')
->required(),
Forms\Components\TextInput::make("new_localization.title")
->label('Title')
->required(),
Forms\Components\Textarea::make("new_localization.body")
->label('Body')
->required(),
]);

return $tabs;
}
protected function getLocalizationTabs(): array
{
$localizations = $this->record->localizations;

$tabs = [];
$data = [];

foreach ($localizations as $localization) {
$data[$localization->id]['body'] = $localization->body;
$data[$localization->id]['title'] = $localization->title;
$data[$localization->id]['locale'] = $localization->locale;
$tabs[] = Forms\Components\Tabs\Tab::make($localization->locale ?? 'New Localization')
->schema([
Forms\Components\TextInput::make("localizations.$localization->id.locale")
->label('Localization')
->required(),
Forms\Components\TextInput::make("localizations.$localization->id.title")
->label('Title')
->required(),
Forms\Components\Textarea::make("localizations.$localization->id.body")
->label('Body')
->required(),
]);
}

$this->data['localizations'] = $data;

$tabs[] = Forms\Components\Tabs\Tab::make('New Localization')
->schema([
Forms\Components\TextInput::make("new_localization.locale")
->label('Localization')
->required(),
Forms\Components\TextInput::make("new_localization.title")
->label('Title')
->required(),
Forms\Components\Textarea::make("new_localization.body")
->label('Body')
->required(),
]);

return $tabs;
}
8 replies
FFilament
Created by y_e_v_h_e_n_i_i on 10/1/2024 in #❓┊help
Using tabs not repeater for dynamic form
seem like i found solution, but it looks not so good
8 replies
FFilament
Created by y_e_v_h_e_n_i_i on 10/1/2024 in #❓┊help
Using tabs not repeater for dynamic form
No description
8 replies
FFilament
Created by y_e_v_h_e_n_i_i on 10/1/2024 in #❓┊help
Using tabs not repeater for dynamic form
just for example screenshot of rendered tabs with form
8 replies
FFilament
Created by y_e_v_h_e_n_i_i on 10/1/2024 in #❓┊help
Using tabs not repeater for dynamic form
sorry this is mistake in this example code. I return $tabs and they renders correctly, but with empty fields
8 replies