Help: How to save data of a related model within a Filament form?
I'm trying to make the title of a
CourseResource
translatable into German and English. However, the translations are not being saved to the course_translations
table.
How can I handle the saving of fillable attributes that are in another table (relationship between 2 models) ?
In the Course model I have this:
And in the CourseTranslations this:
Unfortunately Spaties Translatable plugin doesn't suit my needs. :/
The DB tables exist for both both courses
and course_translations
.
Detailed Code with Course Model, CourseTranslation Model and Course Resource:
https://gist.github.com/Synistic/b033856ec909badfd09e6573feddb98f3 Replies
Your missing the relationship on the field. https://filamentphp.com/docs/3.x/forms/fields/repeater#integrating-with-an-eloquent-relationship
Thank you! I managed to setup the repeater. Is it possible to save HasMany relationsships without an repeater? In my case I will always have 2 translations in the repeater, so 2 fixed sections would be better
No you only have relationship managers or repeaters. You can set the repeater to default to only two and not allow more. https://filamentphp.com/docs/3.x/panels/resources/relation-managers#relation-managers---interactive-tables-underneath-your-resource-forms