tuseto
tuseto
FFilament
Created by tuseto on 10/30/2024 in #❓┊help
Filament repeater translations messed up structure on save
When create repeater first row for the model on bg language the result in the db is: {"bg":[{"name":"first","slug":"first"}],"de":""} Adding second row for same language is okay and the result is: {"bg":[{"name":"first","slug":"first"},{"name":"second","slug":"second"}],"de":""} Then when change the language to en and add the first row in the repeater everything breaks: {"bg":{"d6073341-870a-43f3-bb83-8c49d4df16bf":{"name":"first","slug":"first"},"38b95945-88e1-462b-9e8c-469766af5baf":{"name":"second","slug":"second"}},"en":[{"name":"english_first","slug":"english_first"}]} Composer.lock filament/filament: version: v3.2.121 filament/spatie-laravel-translatable-plugin: v3.3.0 repositories: https://github.com/lara-zeus/translatable (I am using lara-zeus fork of filament-translatable, because as I remember I have problems with file upload for different languages on the original filament-translatable repo) I have a repeater:
Repeater::make('files')
->schema([
TextInput::make('name')->required(),
TextInput::make('slug')->required(),
// FileUpload::make('file'),
])
->columns(2),
Repeater::make('files')
->schema([
TextInput::make('name')->required(),
TextInput::make('slug')->required(),
// FileUpload::make('file'),
])
->columns(2),
files is in my model $translatable fields files is cast as array 'files' => 'array', All model translations works as expected but repeater not.
10 replies
FFilament
Created by tuseto on 10/23/2024 in #❓┊help
How to translate select values
I am using filament spatie translatable plugin. I have a simple select:
Select::make('unit')
->options([
'gr' => 'g',
'ml' => 'ml',
// 'gr' => 'гр',
// 'ml' => 'мл',
]),
Select::make('unit')
->options([
'gr' => 'g',
'ml' => 'ml',
// 'gr' => 'гр',
// 'ml' => 'мл',
]),
Depending on language saved valued should be translated. How I can achieve that?
2 replies
FFilament
Created by tuseto on 6/21/2024 in #❓┊help
Changing language in ListItem does not translate the related records.
I have a translatable resource with EditResource page. I have some relations to this resource, also translatable. But when I am on the edit page of the resource and change language, the related resources stays listed in english. This is my relation in the form schema:
FieldSet::make('Tags')
->schema([
CheckboxList::make('tags')
->relationship(
titleAttribute: 'name',
)
->columns(5),
])
FieldSet::make('Tags')
->schema([
CheckboxList::make('tags')
->relationship(
titleAttribute: 'name',
)
->columns(5),
])
2 replies
FFilament
Created by tuseto on 4/26/2024 in #❓┊help
Cannot search by table columns with same name but one is from relation
Hello I have a table with 2 columns First is the resource name, second is the related customer name. On both I have used ->searchable() . So If I search by resource name the filter works but it works only for the resource name. Even if you comment out first column name and try to search for customer it will continue search only for the resource name. SQL query does not change at all. Always search in the first column name of the resource. First column name of the resource is json but it think this is irrelevant for the issue. If I change customer.name to customer.phone search starts working as usual for both fields. Any ideas how to fix it?
return $table
->columns([
Tables\Columns\TextColumn::make('name')
->searchable()
->sortable(),
Tables\Columns\TextColumn::make('customer.name')
->searchable()
->sortable(),
return $table
->columns([
Tables\Columns\TextColumn::make('name')
->searchable()
->sortable(),
Tables\Columns\TextColumn::make('customer.name')
->searchable()
->sortable(),
Bonus Q: how you handle search in json fields, because it differs from normal fields (because of lower) and this can lead to confusion when working with the product.
5 replies
FFilament
Created by tuseto on 3/16/2024 in #❓┊help
How to test list table search in translatable (via spatie) field with pest
I have the following test:
it('can search page by tistle', function () {
$title = Page::first()->title;

$result = livewire(ListPages::class)
->searchTable($title)
->assertCanSeeTableRecords(Page::where('title->en', $title)->get());
});
it('can search page by tistle', function () {
$title = Page::first()->title;

$result = livewire(ListPages::class)
->searchTable($title)
->assertCanSeeTableRecords(Page::where('title->en', $title)->get());
});
So if the first page title is :
{"en": "asdasdas", "es": "spain"}
{"en": "asdasdas", "es": "spain"}
- the test passes but if it is:
{"bg": "Dolores.", "en": "Aut."}
{"bg": "Dolores.", "en": "Aut."}
- the test fails P.S. locale is EN by default Can you help me what is going on? And how to proper test it?
5 replies