kongulov / nova-tab-translatable

This package contains a NovaTabTranslatable class you can use to make any Nova field type translatable with tabs.
MIT License
79 stars 17 forks source link

Error with nova tabs #39

Open AppDevXXX opened 9 months ago

AppDevXXX commented 9 months ago

Package: composer require shuvroroy/nova-tabs

Requirements PHP (^8.1 or higher) Laravel Nova (^4.12 or higher)

The problem only appears when I use Tabs. The information is saved in the database but the following error appears when saving: Attempt to assign property "name" on null.

My model:

public $translatable = [ 'name' ];

public static function initializeTranslations()
{
    $articleCategory = new ArticleCategory;

    $articleCategory
       ->setTranslation('name', 'en', 'Name in English')
       ->setTranslation('name', 'fr', 'Nom en Français')
       ->save();
}

My Nova resource:

public function fields(NovaRequest $request) { return [ ID::make()->sortable(),

        Tabs::make('General', [
            Tab::make('Main Information', [
                NovaTabTranslatable::make([
                    Text::make('Name', 'name')
                        ->rules('required'),
                ]),
            ]),
            Tab::make('Other', [
                Boolean::make('Active', 'active'),
            ]),
        ]),
    ];
}