Skip to content

fullscreeninteractive/silverstripe-dropdownimagefield

Repository files navigation

SilverStripe DropdownImageField

Adds a DropdownImageField field which enables you to display images alongside the captions. Uses a plugin for Chosen.js (which is used by SS), Image-Select. The plugin is modified.

Working screenshot

Requirements

SilverStripe 6

Install

composer require fullscreeninteractive/silverstripe-dropdownimagefield

Usage

Example:

DropdownImageField::create('Icon', 'Select icon')
    ->setSourceList($this->getAvailableIcons())

...
    /**
     * Get the available icons for the dropdown
     *
     * @return ArrayList<ArrayData>
     */
    public function getAvailableIcons(): ArrayList
    {
        $list = ArrayList::create();
        $icons = [
            'car' => '/_resources/app/images/car.svg'
        ];
    
        foreach ($icons as $key => $value) {
            $list->push(ArrayData::create([
                'ID' => $key,
                'Title' => $key,
                'Image' => $value
            ]));
        }

        return $list;
    }

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •