PHP code example of copperis / dropdownimagefield
1. Go to this page and download the library: Download copperis/dropdownimagefield library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
copperis / dropdownimagefield example snippets
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;
}