How to display fields with different languages in one form without a language switcher?
Hello.
I use this plugin https://filamentphp.com/plugins/filament-spatie-translatable
How to display fields with different languages in one form without a language switcher?
return $form
->schema([
Forms\Components\Section::make()
->schema([
Forms\Components\TextInput::make('title')
->label('(English) Title')
->required()
->maxLength(255),
Forms\Components\TextInput::make('title')
->label('(Hindi) Title')
->required()
->maxLength(255),
Forms\Components\TextInput::make('title')
->label('(Spanish) Title')
->required()
->maxLength(255),
...
12 Replies
you can use my plugin π
Filament
Translatable Inline by Marcus Venghaus - Filament
Addon for Spatie Translatable Plugin to edit translations directly below the field
Hm. Thank you. Is this the only similar solution?
How to divide it into several fields, for example:
return $form
->schema([
Forms\Components\Section::make()
->schema([
Forms\Components\TextInput::make('title')
->label('(English) Title')
->local('en') // <---
->required()
->maxLength(255),
Forms\Components\TextInput::make('title')
->label('(Hindi) Title')
->local('hi') // <---
->required()
->maxLength(255),
...
OR
return $form
->schema([
Forms\Components\Section::make()
->schema([
Forms\Components\TextInput::make('title.en') // <---
->label('(English) Title')
->required()
->maxLength(255),
Forms\Components\TextInput::make('title.hi') // <---
->label('(Hindi) Title')
->required()
->maxLength(255),
...
you can replace the casting spatie's module is doing .. result should be an array .. but you can cast it from different fields
Can you make a working example please? It's still hard for me to understand.
sorry .. no time for that at the moment .. tomorrow
just make sure your data is that kind of array .. convert you data before and after back
I will be very grateful if you can make a working example tomorrow. Thank you.
And it would be great to add this feature to your plugin.
Hello. Can you make an example today?
(
make sure you cast to array and the second one should work
there is many ways to do it
this is an example:
I am using tabs in blade file
in each tab there is a text input
and cast
title
to array
https://github.com/lara-zeus/chaos/blob/1.x/src/Forms/Components/MultiLang.phpGitHub
chaos/src/Forms/Components/MultiLang.php at 1.x Β· lara-zeus/chaos
opinionated filament setup. Contribute to lara-zeus/chaos development by creating an account on GitHub.
Thank you. Please show me an example of using the MultiLang Component. And a screenshot of what UI looks like.
MultiLang::make('title)
It would be great if there was such a plugin with advanced settings.
create one π