Skip to content
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

Fix uploads in relationship repeatables #5420

Merged
merged 4 commits into from
Jan 10, 2024

Conversation

pxpm
Copy link
Contributor

@pxpm pxpm commented Jan 10, 2024

WHY

BEFORE - What was wrong? What was happening before this PR?

A lot of stuff were broken and there were many issues reported regarding uploaders in relationships. I've been pushing small fixes but never got to the end of the issue because the problem was the implementation as a whole and not only small broken bits.

#5355
#5299
https://stackoverflow.com/questions/77794931/backpack-6-repeatable-with-file-upload-field

AFTER - What is happening after this PR?

The uploaders should properly work on repeatable relationships

HOW

How did you achieve that, in technical terms?

I needed to re-work the whole saving process for repeatable relationships in the uploaders.
In the end we endup with more customized uploaders, tailored each for their needs without having to guess what belongs to where, that was causing most of the issues.

Docs were updated too. Most noticeable change in docs is the mention that "uploaders in relationships should NOT be casted in the models". Laravel-Backpack/docs#537

This is a limitation by the fact that we hook to the "saving" event and if they are casted we can't get the sent files from the entry (only from request), and the request is not reliable due to the nature of how repeatable works.

Is it a breaking change?

No I don't think so.

How can we test the before & after?

Just trying to add a file uploader to any relationship will be enough to get into a broken scenario.

@pxpm pxpm merged commit f5ee627 into main Jan 10, 2024
3 checks passed
@pxpm pxpm deleted the fix-uploads-in-relationship-repeatables branch January 10, 2024 18:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants