How to model one-to-many and allow "many" updates inside the "one" form?

I am making an application that allows users to review and update handwritten feedback forms. Each feedback form has one or more comments on it. Presently, I am modelling this as a JSON column - using an array of strings (each string is a comment). I could equally model this using a separate database table. I am looking for advice on the best way to do this so that I can add, edit and remove comments within the feedback form edit screen. I started trying to create a custom ViewField, but I don't know Filament well enough to know whether this approach is likely to work. Those of you more experienced with Filament, how would you do this? I imagine a similar sort issue could come up anywhere you want to edit the "many" in a one-to-many relationship from the "one" screen. For example, adding tags to a post, categories to a product, etc etc.
Solution:
You may use Repeater component, suppose feedback hasMany comments
Jump to solution
2 Replies
Solution
BKF Dev
BKF Dev4mo ago
You may use Repeater component, suppose feedback hasMany comments
jamespickard
jamespickardOP4mo ago
Ah yes, this works well, thank you. I will have to change things a bit since Repeater seems to expect an array of object, rather than an array of strings and sadly the very helpful mutateRelationshipDataBeforeFillUsing seems to only get called for Eloquent relations and not when using JSON columns. Ah, there is simple() specifically for that, nice!
Want results from more Discord servers?
Add your server