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

UploadField fails to attach when uploading multiple files in inline editing mode #1264

Open
2 tasks done
kinglozzer opened this issue Nov 4, 2024 · 2 comments
Open
2 tasks done

Comments

@kinglozzer
Copy link
Member

Module version(s) affected

5.3.0

Description

When uploading files to an UploadField in inline editing mode, if multiple files are uploaded at once they will fail to attach after they finish uploading. They upload successfully, but the field never updates to reflect this - they just disappear. Uploading one at a time works fine, and so does uploading in non inline editing mode. 1st half of video shows this.

This issue also seems to affect UploadFields that are restricted to a single file - if you try to upload multiple files, the error to say you can’t do this appears briefly and then disappears again. 2nd half of video shows this.

Screen.Recording.2024-11-04.at.10.00.35.mov

How to reproduce

Upload a single file, observe that it’s attached after it finishes uploading. Upload two files at once, observe that they disappear after they’ve finished uploading.

Code snippet below:

<?php

declare(strict_types=1);

namespace App\Model\Elements;

use DNADesign\Elemental\Models\BaseElement;
use SilverStripe\AssetAdmin\Forms\UploadField;
use SilverStripe\Assets\Image;
use SilverStripe\Forms\FieldList;

class ElementLogos extends BaseElement
{
    private static string $table_name = 'ElementLogos';

    private static array $has_one = [
        'Test' => Image::class,
    ];

    private static array $many_many = [
        'Logos' => Image::class,
    ];

    private static array $many_many_extraFields = [
        'Logos' => [
            'SortOrder' => 'Int',
        ],
    ];

    private static array $owns = [
        'Test',
        'Logos',
    ];

    private static array $cascade_deletes = [
        'Test',
        'Logos',
    ];

    private static array $cascade_duplicates = [
        'Test',
        'Logos',
    ];

    private static string $singular_name = 'logos block';

    private static string $plural_name = 'logo blocks';

    private static string $description = 'Logos block';

    private static string $icon = 'font-icon-block-carousel';

    public function getCMSFields(): FieldList
    {
        $this->beforeUpdateCMSFields(
            function (FieldList $fields) {
                $fields->removeByName(
                    [
                        'Test',
                        'Logos',
                    ]
                );

                $fields->addFieldsToTab(
                    'Root.Main',
                    [
                        UploadField::create('Test', 'Test')
                            ->setAllowedFileCategories(IMAGE_SUPPORTED)
                            ->setFolderName('logos'),
                        UploadField::create('Logos', 'Logos')
                            ->setAllowedFileCategories(IMAGE_SUPPORTED)
                            ->setFolderName('logos')
                    ]
                );
            }
        );

        return parent::getCMSFields();
    }

    public function getType(): string
    {
        return 'Logos';
    }
}

Possible Solution

No response

Additional Context

I was going to open this against asset-admin but it only affects inline editing mode, so I guess regardless of which codebase causes the issue it’s better to track it here.

Validations

  • Check that there isn't already an issue that reports the same bug
  • Double check that your reproduction steps work in a fresh installation of silverstripe/installer (with any code examples you've provided)
@GuySartorelli
Copy link
Member

Thanks for reporting this.
Just to confirm, have you tested this in 5.2 (i.e. is this a regression that's new to 5.3.0 specifically)?

@kinglozzer
Copy link
Member Author

Just tested against a site running 5.2 (for both elemental and admin/framework) and this bug does exist in that version

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants