Skip to content

Adds a visual field to Silverstripe that uses images as radio buttons

Notifications You must be signed in to change notification settings

Iliain/silverstripe-visualfields

Repository files navigation

Silverstripe Visual Fields

Latest Stable Version Total Downloads Latest Unstable Version License PHP Version Require

Provides similar functionality to heyday/silverstripe-colorpalette, but uses images rather than colours.

Installation (with composer)

$ composer require iliain/silverstripe-visualfields

Usage

$fields->addFieldToTab('Root.Main', $layoutField = VisualOptionField::create('BlockLayout', 'Layout', [
    'layout-1' => $layoutFolderPath . '/layout-1.png',
    'layout-2' => $layoutFolderPath . '/layout-2.png'
]));

Visual Fields

Customising

You can customise the size and background colour of the images with the following options:

$layoutField->setOptionWidth('250px');
$layoutField->setOptionHeight('150px');
$layoutField->setOptionBackgroundColour('#f0f0f0'); // Only visible if the image has transparency

Visual Fields