MadeHQ/silverstripe-cloudinary

'setMultiple' does not exist on 'MadeHQ\Cloudinary\Forms\ImageField'

Opened this issue · 1 comments

I couldn't find the setMultiple method in the codebase. Is it supported? Here's my code based on your documentation. Please let me know if I'm doing something wrong.

<?php

use MadeHQ\Cloudinary\Forms\FileField;
use MadeHQ\Cloudinary\Forms\ImageField;
use MadeHQ\Cloudinary\Forms\MediaField;
use SilverStripe\CMS\Model\SiteTree;

class Page extends SiteTree
{

    private static array $db = [
        'MainImage' => 'CloudinaryImage',
        'BackgroundVideo' => 'CloudinaryMedia',
        'Brochure' => 'CloudinaryFile',
        'ImageGallery' => 'CloudinaryMultiImage',
        'VideoGallery' => 'CloudinaryMultiMedia',
        'Downloads' => 'CloudinaryMultiFile',
    ];

    private static array $has_one = [];

    public function getCMSFields()
    {
        $fields = parent::getCMSFields();

        // Single asset fields
        $fields->addFieldToTab('Root.Main', ImageField::create('MainImage'));
        $fields->addFieldToTab('Root.Main', MediaField::create('BackgroundVideo'));
        $fields->addFieldToTab('Root.Main', FileField::create('Brochure'));

        // Multiple asset fields
        $fields->addFieldToTab('Root.Main', ImageField::create('ImageGallery')->setMultiple(true));
        $fields->addFieldToTab('Root.Main', MediaField::create('VideoGallery')->setMultiple(true));
        $fields->addFieldToTab('Root.Main', FileField::create('Downloads')->setMultiple(true));

        return $fields;
    }
}

setmultiple error

Hey @ishannz that's actually no longer required, we introduced specific fields for multiple resources.

MultiFileField::create('Downloads')
MultiImageField::create('ImageGallery')
MultiMediaField::create('VideoGallery')

You can also do:

$this->dbObject('Downloads')->scaffoldFormField()
$this->dbObject('ImageGallery')->scaffoldFormField()
$this->dbObject('VideoGallery')->scaffoldFormField()

I need to update the read me. There's been a few updates since I first wrote it, so I will eventually get around to updating the read me.

Feel free to post issues or questions and I'll be happy to get back to you.