Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doesn't save translations with Nova repeater #106

Open
Arturas0 opened this issue Sep 29, 2023 · 2 comments
Open

Doesn't save translations with Nova repeater #106

Arturas0 opened this issue Sep 29, 2023 · 2 comments

Comments

@Arturas0
Copy link

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"}}]
rolw with text translatable

As temporary solution I use KeyValue field, as it saves information in json correctly.
role with dates workaround

I'm using the following:

Laravel framework 10.25.1
Nova 4.27.13
PHP 8.2
Nova translatable 2.2.0

@wajdijurry
Copy link

Maybe this would help:
emilianotisato/nova-tinymce#62

@cereneto
Copy link

cereneto commented Mar 7, 2024

Same issue here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants