This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

iSnaker
iSnaker

I trying to make attachMany file relation in theme Settings section of October CMS. In my own plugin i wrote

use Cms\Classes\Theme;
use Cms\Models\ThemeData;
use System\Classes\PluginBase;
use System\Models\File;

class Plugin extends PluginBase
{
    public function boot()
{
    ThemeData::extend(function($model){
        $model->attachMany = [ "images" => File::class ];
    });
}

public function registerComponents()
{
}

public function registerSettings()
{
}
}

And in theme.yaml of my theme

form:
    fields:
        images:
            label: images
            mode: image
            useCaption: true
            imageWidth: '100'
            thumbOptions:
                mode: crop
                extension: auto
            span: auto
            type: fileupload

So in Backend->Settings->CMS->Front-end Theme appeared new button "Customize" and my field images inside. But when i choose Upload I can select only one file!

So it works like attachOne instead of attachMany. Seems like the boot() method of Plugin doesn't work at all.

What am I doing wrong?

mjauvin
mjauvin

The theme model is special and automatically assign fields of type "fileupload" to its $attachOne relation.

ref. https://github.com/octobercms/october/blob/master/modules/cms/models/ThemeData.php#L127-L130

Last updated

mjauvin
mjauvin

Please see this Pull Request if you want to use this:

https://github.com/octobercms/october/pull/4933

gerafinnes53679
gerafinnes53679

marc.jauvin24240 said:

The theme model is special and automatically assign fields of type "fileupload" to its $attachOne relation.

ref. https://motox3m.co/ https://github.com/octobercms/october/blob/master/modules/cms/models/ThemeData.php#L127-L130

Thanks@marc.jauvin24240 . I have done like instruction

1-4 of 4

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.