No description
  • PHP 78.7%
  • CSS 12.6%
  • Scheme 8.7%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2026-10-27 13:44:00 +01:00
_config main back to 1.0 2026-10-27 13:44:00 +01:00
code main back to 1.0 2026-10-27 13:44:00 +01:00
css main back to 1.0 2026-10-27 13:44:00 +01:00
templates/UncleCheese/Forms main back to 1.0 2026-10-27 13:44:00 +01:00
tests main back to 1.0 2026-10-27 13:44:00 +01:00
_config.php main back to 1.0 2026-10-27 13:44:00 +01:00
composer.json main back to 1.0 2026-10-27 13:44:00 +01:00
LICENSE main back to 1.0 2026-10-27 13:44:00 +01:00
README.md main back to 1.0 2026-10-27 13:44:00 +01:00

This is a form from unclecheese/silverstripe-image-optionset with SilverStripe 6 Support

Image OptionsetField

Provides a list of selectable items that use images as the primary label instead of text.

Screenshot

Installation

composer require moritz-sauer-13/silverstripe-image-optionset

Configuration

You can configure the default width and height of the images.

UncleCheese\Forms\ImageOptionsetField:
  default_image_width: 300
  default_image_height: 300

Usage

Simple example:

$field = ImageOptionsetField::create('Template', 'Select a template')
                ->setSource([
                    'sidebar' => [
                        'title' => 'Sidebar page',
                        'image' => '/path/to/sidebar.png'
                    ],
                    'block' => [
                        'title' => 'Block page',
                        'image' => '/path/to/block.png'
                    ]
                ]);

// Use a custom image width and height
$field->setImageWidth(100);
$field->setImageHeight(100);

If you're not using titles, you can use image paths as the values rather than nested arrays.

$field = ImageOptionsetField::create('Template', 'Select a template')
                ->setSource([
                    'sidebar' => '/path/to/sidebar.png'
                    'block' => '/path/to/block.png'
                ]);

Tests

tests/ImageOptionsetFieldTest

Troubleshooting

Ring Uncle Cheese.