-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
File Upload forms does not work with Relation Behavior and Pivot Model #1600
Comments
+1 I'm encountering the same issue. owning model RichIndexPage
Relation model RichBlock
|
It has to do with deferred binding messing up, if I add this in
then it works ish, although the ajax postback still fails miserably. So to summarise, the call actually arrives at it's destination, with all proper variables, it finds the relation and gets that, no problems. But the ajax postback doesn't get called, and the deferred binding does not get executed when the final form is saved. Basically if you click the delete button of an image it will delete it visually, make the deferred binding table entry, but the loading bar will keep loading and the mouse pointer will keep as a loading icon and it will never stop, but neither will it throw an error. If you try to edit the File details(name and description) and try to save that you get an exception that relationRichblockManagePivotFormImage has not been bound to the controller.... |
I made a dirty workaround to allow me to do both things in the mean time... in the relation render fields yaml add a partial where you will define your form fields for the pivot data
Then in your Model(mine is RichBlock)
|
In fact there is two problems by using an attachment in a pivot model:
For the first problem, you can fix it by specify the session key in the save lines in modules/backend/behaviors/RelationController.php:
For the second problem, I guess that a pivot model is identified by two ids (the associated models), and not by a main integer. But the system_files table needs an id to identify the model where the file is associated. There is many solutions to this problem, but that is not a simple change:
|
Ok, I found a solution to my problem. The patch above is needed, and you also need to add some attributes to your pivot table:
Both attributes must be declared in the schema database and declared pivot attributes in the parent model. Now the system_files table is correctly filled. |
In the documentation and in #1409 it says deferred binding is not supported for pivot data. But I wonder if my fix is enough to enable deferred binding, it seems to work, no? |
Fixed by #1641 |
I can't attach file in pivot relation Manager. How I can do it? |
Pivot models do not use a primary key and are therefore not compatible with system files or deferred binding so cannot be used with the |
When you add a file upload form in a pivot field in the controller's relation configuration, the attachment is not saved/attached with the pivot model: the image is uploaded, an entry seems to be added in system_files table, but after saving the page, the association between the pivot table and system_files is not correctly saved.
The text was updated successfully, but these errors were encountered: