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 Apply multiupload auto-detection for upload fields #1108

Merged

Conversation

GuySartorelli
Copy link
Member

UploadField checks hasone components based on the field name to see if it can be a multiUpload field or not. We need to trigger that before changing the name of the field.

Issue

UploadField checks hasone components based on the field name to see if
it can be a multiUpload field or not. We need to trigger that before
changing the name of the field.
Copy link
Member

@emteknetnz emteknetnz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well that was easy :-)

Tested locally, works good

@emteknetnz emteknetnz merged commit 6e3180c into silverstripe:4.11 Oct 11, 2023
12 checks passed
@emteknetnz emteknetnz deleted the pulls/4.11/fix-hasone-file branch October 11, 2023 05:24
@emteknetnz
Copy link
Member

In case anyone's interested here's the code I used to validate the before and after

<?php

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

class MyElement extends BaseElement
{
    private static array $has_one = [
        'MyFile' => File::class
    ];

    public function getType()
    {
        return 'My block';
    }

    public function getCMSFields()
    {
        $fields = parent::getCMSFields();
        $fields->addFieldToTab('Root.Main', new UploadField('MyFile', 'MyFile'));
        return $fields;
    }
}

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