SilverStripe field for providing arbitrary text input or selecting from YAML configurable presets.
SilverStripe 3+
(the 'Link Text' field demonstrates a FlexiChoiceField
,
the 'Link' field is a silverstripe-flexilink field)
- Add
FlexiChoice
field types to yourDataObject
(s)
class BlockContentHeading extends DataObject {
private static $db = array(
'Title' => 'Varchar',
'Content' => 'Text',
'Link' => 'FlexiLink',
'LinkText' => 'FlexiChoice', // <--- here
);
Trigger the environment builder (/dev/build) after extending objects --
You will now see the FlexiChoiceField
appear in the CMS when editing your
object.
- Define presets in YAML Configuration
FlexiChoiceField:
choices:
- LEARN MORE
- READ MORE
- MORE
- GET STARTED
You may of course subclass FlexiChoiceField
to provide multiple fields with
different choice selections.