Skip to content

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

@lozcalver

Description

@lozcalver

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)

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions