FormBuilder Repeaters capable of handling Media through Pivot? #2467
Unanswered
CameronCarranza
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Description
I have a Product Model (Project in the guide) and a Category Model (Partner in the guide) and am using the following guide https://twillcms.com/docs/relations/belongs-to-many.html to allow the creation/editing of Categories from the Product page via a FormBuilder InlineRepeater.
Normal fields all work properly, and saving Media works (initially) however, media fields appear to be trying to load using the Category ID and not the Pivot ID, so upon a refresh the Media is blank on the Product page but does exist on the Category page. A subsequent save on the Product page will wipe the image from the Category
Using
dd
withingetFormFields
onProductRepository.php
on thegetFormFieldForRepeaterWithPivot
method I noticed the following:The Media is mismatched and using the Category ID rather than the repeater pivot ID
I copy pasted getFormFieldForRepeaterWithPivot from HandlerRepeaters.php into ProductRepository.php and added the following to apply a fix just for that specific Repeater Type:
This makes it work properly as far as I can tell, saving, updating, deleting the media is working as well as the usual fields. In the
dd
s above the ID is changed in repeaterMedias from categories-5 to categories-6.I am not sure if this is the correct fix, or if this is even technically supported as the JSON Repeaters were stated to not support Media but was unclear on whether the FormBuilder Inline Repeaters. Either way, this does appear to work for now but would love to know if there is a better way or if this is isolated to me. Thanks!
Steps to reproduce
Stepping through the guide linked above and also adding a Media field to the repeater.
Expected result
Media should display within the repeater
Actual result
Media is always blank, but does save to the Model until you update the page again with the blank field and then it gets wiped.
Versions
3.0.2
10.25.2
8.1.18
mariadb:10.6
Beta Was this translation helpful? Give feedback.
All reactions