nova-translatable
nova-translatable copied to clipboard
Doesn't save translations with Nova repeater
When I use a translatable Text field in Repeater component, translatable field information is not saved to json field, instead it saves as null.
Nova field in resource:
BelongsToMany::make('Professionals', 'professionals', Professional::class)->fields(static function () {
return [
Repeater::make('Role with dates', 'dates')
->repeatables([
RoleWithDates::make(),
])
->asJson()
];
})
Repeater component code:
class RoleWithDates extends Repeatable
{
public function fields(NovaRequest $request): array
{
return [
Text::make('Role')
->nullable()
->translatable(),
Date::make('Start date', 'start')
->rules('nullable', 'date')
->resolveUsing(function ($value) {
return $value;
}),
Date::make('End date', 'end')
->rules('nullable', 'date', 'before_or_equal:today')
->resolveUsing(function ($value) {
return $value;
}),
];
}
If I fill information in database directly, then translatable Text field can display information without problem.
Working json example:
[{"type": "role-with-date", "fields": {"end": "2023-09-10", "role": {"en": "swimmer", "lt": "plaukikas", "pl": "", "ru": ""}, "start": "2023-09-01"}}]
As temporary solution I use KeyValue field, as it saves information in json correctly.
I'm using the following:
Laravel framework 10.25.1 Nova 4.27.13 PHP 8.2 Nova translatable 2.2.0
Maybe this would help: https://github.com/emilianotisato/nova-tinymce/issues/62
Same issue here.