-
Notifications
You must be signed in to change notification settings - Fork 2
Home
Nathan Cox edited this page Aug 14, 2013
·
3 revisions
This is the start of a SilverStripe 3 module for creating radio button fields with a more custom appearance.
At the moment it's only tested with images in place of radio buttons/labels but will ideally take whole HTML blocks.
<?php
// in getCMSFields
// set up a field to pick an icon for this page
$icons = array(
'user',
'user-female',
'user-white',
'user-white-female',
'user-yellow',
'user-yellow-female',
'user-green',
'user-green-female'
);
$makeOption = function($iconName) {
return "<img src='mysite/images/treeicons/" . $iconName . ".png' alt='' />";
};
$options = array();
foreach($icons as $iconName) {
$options[$iconName] = $makeOption($iconName);
}
$fields->addFieldtoTab('Root.Settings', $iconField = new HTMLOptionsetField(
'Icon',
'Tree icon',
$options
));
Result:
Note: Icons are from the Fugue icon set (http://p.yusukekamiyamane.com/).