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

[Bug] Upload Field Inside Relationship Field Not Working Correctly #5717

Open
misiekch opened this issue Nov 9, 2024 · 2 comments
Open

[Bug] Upload Field Inside Relationship Field Not Working Correctly #5717

misiekch opened this issue Nov 9, 2024 · 2 comments

Comments

@misiekch
Copy link
Contributor

misiekch commented Nov 9, 2024

Bug report

What I did

I am using relationship field to create contracts for my projects. Every contract has a multiple upload field:

CRUD::addFields([
    [
        'name' => 'name',
        'type' => 'text',
    ], [
        'name' => 'contracts',
        'type' => 'relationship',
        'subfields' => [
            [
                'name'  => 'name',
                'type'  => 'text',
            ], [
                'name'  => 'attachments',
                'type'  => 'upload_multiple',
                'withFiles' => [
                    'disk' => 'projects',
                ],
            ]
        ],
    ],
]);

I wanted to attach files to one of the added contracts:

Screenshot (1)

What I expected to happen

Uploaded files should be attached to one contract only.

What happened

When I saved the form, the uploaded files were attached to all of the contracts.

Screenshot (2)

What I've already tried to fix it

Last working backpack/crud version is 6.4.1

Is it a bug in the latest version of Backpack?

After I run composer update backpack/crud the bug... is it still there?

Yes, since backpack/crud:6.4.2

Backpack, Laravel, PHP, DB version

When I run php artisan backpack:version the output is:

PHP VERSION:

8.2.22

LARAVEL VERSION:

10.48.22.0

BACKPACK PACKAGE VERSIONS:

backpack/basset: 1.3.6
backpack/crud: 6.7.41
backpack/generators: v4.0.7
backpack/pro: 2.2.22
backpack/theme-tabler: 1.2.15

Copy link

Thank you for reporting this issue. It appears you're experiencing a bug with the upload_multiple field inside a relationship field in Backpack CRUD. This is a known issue that has been reported and addressed in recent versions of Backpack.

Based on the information provided in the Github Issue #5392, this bug was fixed in Backpack CRUD version 6.4.2. However, you're using version 6.7.41, which is more recent, so the bug should have been resolved.

Here are a few things you can try:

  1. Make sure you're using the latest Uploaders feature. According to the fix for uploaders in repeatable relationships, the way uploads are handled in relationships has been improved.

  2. Check if you're using the correct syntax for the withFiles option. The correct syntax should be:

    'withFiles' => [
        'disk' => 'projects',
        'path' => 'your_path_here',
    ],

    Make sure to specify a path if you want the files to be stored in a specific directory on your disk.

  3. If you're still experiencing issues, it might be worth checking if there are any conflicts with your specific implementation or if there's a new bug that hasn't been reported yet.

If the problem persists after trying these steps, I recommend opening a new issue on the Backpack CRUD GitHub repository with a detailed description of your setup and the steps to reproduce the bug.

Remember to always back up your data before making changes to your application or updating packages.

Relevant sources:

Github Issue (closed): [Bug] "upload_multiple" field within subfields of a "relationship" field does not allow files to be deleted
Github Issue (closed): [Bug] The file field that was used within the relationship's subfields, was not sent with the request
Github Issue (closed): Multiple Upload doesn't work in a relationship with subfields
Github Issue (closed): [Bug] upload and upload_multiple fields don't work as subfields inside relationship
Github Issue (closed): [Bug] Uploaded files cannot be deleted
Github Issue (closed): Upload in a relationship with subfield
Github Issue (open): [Bug] Upload subfield contains wrong url in repeteable relationship field
Github Issue (closed): [Bug] Multiple upload in a relationship does not work with Spatie/MediaLibrary
Handle uploads inside relationships

@karandatwani92
Copy link
Contributor

karandatwani92 commented Nov 11, 2024

Hey @misiekch

Thanks for reporting the BUG. We have a PR ready that fixes uploader-related issues, but the fix leads to breaking changes.

Thus, We'll be launching Backpack v7, hopefully at the end of this month or next, which will cover uploader fixes and many other features/fixes that require breaking changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: No status
Status: No status
Development

No branches or pull requests

2 participants