silverstripe / silverstripe-framework

Silverstripe Framework, the MVC framework that powers Silverstripe CMS
https://www.silverstripe.org
BSD 3-Clause "New" or "Revised" License
721 stars 821 forks source link

[2012-07-07] UploadField sets incorrect FileName in Files Table #1530

Closed silverstripe-issues closed 10 years ago

silverstripe-issues commented 11 years ago

created by: Emaster created at: 2012-07-07 original ticket: http://open.silverstripe.org/ticket/7631


When using the code example in /framework/forms/UploadField.php to upload multiple files the file uploads but the File Name is not set correctly in the Files Database Table.

'''What happens:'''

'''Workaround:'''


<?php

/* /mysite/code/TestPage.php */

class TestPage extends Page
{
    static $has_many = array(
        'Images' => 'Image',
    );

    public function getCMSFields(){

        $fields = parent::getCMSFields();

        /* Example Code from https://github.com/silverstripe/sapphire/blob/master/forms/UploadField.php */
        $UploadField = new UploadField('Images', 'Please upload some images <span>(max. 5 files)</span>');
        $UploadField->getValidator()->setAllowedExtensions(array('jpg', 'jpeg', 'png', 'gif'));
        $UploadField->setConfig('allowedMaxFileNumber', 5);
        $fields->addFieldToTab('Root.Files', $UploadField);
        /* End Example Code */

        return $fields;

    }
}
simonwelsh commented 10 years ago

This is no longer an issue, also, don't has_many to Image.