TypiCMS / Base

Multilingual CMS built with Laravel.
MIT License
1.4k stars 404 forks source link

Cannot translate attribute `title` as it's not one of the translatable attributes: `status` #253

Closed bibekstan closed 1 year ago

bibekstan commented 1 year ago

I have created a custom module named Newletters where it has only email and status field. However the scaffolding generated by typicms has title, slug, status, body, summary as translatable by default in the model. Now when I tried to remove these unwanted field from $translatable attribute in the model, it gives me the error: Cannot translate attribute title as it's not one of the translatable attributes: status

By default it has: public $translatable = [ 'title', 'slug', 'status', 'summary', 'body', ];

But I want: public $translatable = [ 'status', ];

sdebacker commented 1 year ago

Please have a look at the package documentation or the Laravel one as this is not strictly related to TypiCMS.

bibekstan commented 1 year ago

@sdebacker The scaffolding auto sets up an observer to check for title and slug to be translatable items while creating a record. So, if you dont need the title and slug to be checked while creating the rows, you can comment or remove the observer Module/MyModule/Providers/ModuleServiceProvider.php file. The observer looks like: MyModule::observe(new SlugObserver()); Need to comment this line