whitecube / nova-flexible-content

Flexible Content & Repeater Fields for Laravel Nova
MIT License
785 stars 228 forks source link

Problem with spatie/nova-translatable and kongulov/nova-tab-translatable #269

Open dnwjn opened 3 years ago

dnwjn commented 3 years ago

Hi!

I'm trying to get this to work in combination with either spatie/nova-translatable or kongulov/nova-tab-translatable. I've read possibilities in #7, #33, #39, #44 and #58, but I've been unable to get it to work.

With spatie/nova-translatable

Here I set it up as follows:

Flexible::make('Specifications')
    ->addLayout('Specification', 'specification', [
        Text::make('Key'),

        Translatable::make([
            Text::make('Value'),
        ]),
    ]),

This gives me the following error:

Argument 1 passed to Whitecube\NovaFlexibleContent\Layouts\Layout::cloneField() must be an instance of Laravel\Nova\Fields\Field, instance of Spatie\NovaTranslatable\Translatable given, called in .../vendor/whitecube/nova-flexible-content/src/Layouts/Layout.php on line 223

.../vendor/whitecube/nova-flexible-content/src/Layouts/Layout.php#245

     * @param  \Laravel\Nova\Fields\Field $original
     * @return \Laravel\Nova\Fields\Field
     */
    protected function cloneField(Field $original) {
        $field = clone $original;

        $callables = ['displayCallback','resolveCallback','fillCallback','requiredCallback'];

With kongulov/nova-tab-translatable

Here I set it up as follows:

Flexible::make('Specifications')
    ->addLayout('Specification', 'specification', [
        Text::make('Key'),

        NovaTabTranslatable::make([
            Text::make('Value'),
        ]),
    ]),

This gives me a different error:

Argument 2 passed to Kongulov\NovaTabTranslatable\NovaTabTranslatable::Kongulov\NovaTabTranslatable\{closure}() must be an instance of Illuminate\Database\Eloquent\Model, instance of Whitecube\NovaFlexibleContent\Layouts\Layout given

.../vendor/kongulov/nova-tab-translatable/src/NovaTabTranslatable.php#106

        $translatedField
            ->resolveUsing(function ($value, Model $model) use ($translatedField, $locale, $originalAttribute) {
                $translatedField->attribute = 'translations_' . $originalAttribute . '_' . $locale;
                $translatedField->panel = $this->panel;

My project dependencies

"php": "^7.4",
"ext-json": "*",
"aws/aws-sdk-php": "~3.0",
"bensampo/laravel-enum": "^3.1",
"biscolab/laravel-recaptcha": "^4.4",
"codezero/laravel-localized-routes": "^2.4",
"comodolab/nova-help": "^0.4.0",
"dnwjn/nova-launch": "*",
"ebess/advanced-nova-media-library": "^3.3",
"emilianotisato/nova-tinymce": "^1.1",
"epartment/nova-dependency-container": "^1.3",
"facade/ignition": "^2.3.7",
"fideloper/proxy": "^4.0",
"guzzlehttp/guzzle": "^7.0.1",
"kongulov/nova-tab-translatable": "^1.0",
"laravel/framework": "^8.0",
"laravel/horizon": "^5.3",
"laravel/legacy-factories": "^1.0",
"laravel/nova": "*",
"laravel/tinker": "^2.0",
"laravel/ui": "^2.2",
"laravelcollective/html": "^6.1",
"lorisleiva/laravel-deployer": "0.3.*",
"optimistdigital/nova-settings": "^2.5",
"predis/predis": "^1.1",
"sentry/sentry-laravel": "^2.3",
"spatie/laravel-medialibrary": "^8.0.0",
"spatie/laravel-permission": "^3.17",
"spatie/laravel-sitemap": "^5.8",
"spatie/laravel-sluggable": "^2.6",
"spatie/laravel-translatable": "^4.5",
"spatie/nova-translatable": "^3.0",
"whitecube/nova-flexible-content": "^0.2.8"

Is there a way to fix this? Or do I need to write a custom layout or resolver for this, or even something like https://whitecube.github.io/nova-flexible-content/#/?id=usage-with-ebessadvanced-nova-media-library?

Thanks in advance!

bastihilger commented 3 years ago

Hi there - I use a different package for translations with nova-flexible-content: optimistdigital/nova-translatable. This also uses spatie/translatable under the hood and works fine, maybe it fits your needs?

dnwjn commented 3 years ago

Hi there - I use a different package for translations with nova-flexible-content: optimistdigital/nova-translatable. This also uses spatie/translatable under the hood and works fine, maybe it fits your needs?

Thanks for your suggestion, I'm absolutely gonna try it out!

czemu commented 2 years ago

Hi there - I use a different package for translations with nova-flexible-content: optimistdigital/nova-translatable. This also uses spatie/translatable under the hood and works fine, maybe it fits your needs?

Hi @manogi

How did you get it to work? The translatable() method from the optimistdigital/nova-translatable package doesn't seem to work with the flexible fields in my case. The language links are not displayed.

image

image

czemu commented 2 years ago

I figured it out. The translatable() method must be added to each field inside flexible layout, not for the whole group as I did.

Anyway, thanks for recommending the package.

vankov1 commented 1 year ago

@dnwjn Did you find solution for kongulov/nova-tab-translatable?

dnwjn commented 1 year ago

@dnwjn Did you find solution for kongulov/nova-tab-translatable?

I switched to optimistdigital/nova-translatable, sorry...