InlineRepeater deleting data on related Model entries
I'm using an InlineRepeater to add relations with pivot data between two Repositories. The relations and pivot data are being stored as expected, but I just realized that when I update the entry, it is also deleting Media and Block data for the related model entry. I just lost a good bit of work to this.
I have a repository
Location
and a repository Taxa
, with a location_taxa
many-to-many pivot table to connect the two.
In the Taxa
model, I've created this relation:
In my TaxaController
, I've configured the InlineRepeater as such:
This stores the relationship and details
in the pivot table as expected. I'm not sure why it's also accidentally destroying the data10 Replies
This is a pretty devastating blocker for this project and so any help is greatly appreciated.
Looking at the payload from saving the Taxa, I can only guess it's because the
blocks
and medias
fields are empty here, but I don't know how I would go about changing this behavior. Why is it sending/saving more than just the pivot field(s)?Hey @daniel Twill 3.1 is out now so I'll try to spend more time to help here. Any chance you could provide a quick repro for this? That'll help expedite getting the support you need if you can
Maybe that's not needed after reviewing everything you shared
I see what's going on
Ok great
@ifox any more thoughts on this one?
@daniel you're using
updateRepeaterWithPivot
, right?@ifox yeah,
updateRepeaterWithPivot
and getFormFieldForRepeaterWithPivot
ok, so our implementation has only been used for simple related models where all the fields from that model would be in the repeater (not just the title like you have). As in, the associated content is created inline and the related module isn't exposed standalone in the CMS where it could have medias and blocks etc...
since you only ever want to update the pivot fields can you try to comment out this line https://github.com/area17/twill/blob/063b4bbbe2b133f48008de250be8f767ce2350c1/src/Repositories/Behaviors/HandleRepeaters.php#L219? If that works you can override the function in your project for now and we could just add an option or another method to achieve your use case. It makes a lot of sense to me, we just haven't structured our form that way
GitHub
twill/src/Repositories/Behaviors/HandleRepeaters.php at 063b4bbbe2b...
Twill is an open source CMS toolkit for Laravel that helps developers rapidly create a custom admin console that is intuitive, powerful and flexible. Chat with us on Discord at https://discord.gg/c...
To clarify, the inline repeater as it is currently implemented is meant to write into the related model too (hence inline), not just the pivot
but we can easily add what you need to only edit the pivot
this worked! thank you so much.
just curious -- is there another method that would be more "standard" for my use case? or am I just doing something that hadn't been considered before? either way, really glad that there's a workaround for it. eventual official support would of course be awesome.
thank you again!
Awesome, yeah it's just that it hasn't been considered
It will! And I'll let you know when you can remove your override