I have a Dataobject in ModelAdmin with the following fields:
class NavGroup extends DataObject {
private static $db = array(
'GroupType' => 'Enum("Standard,NotStandard","Standard")',
'NumberOfBlocks' => 'Int'
);
public function getCMSFields() {
$groupTypeOptions = singleton('NavGroup')->dbObject('GroupType')->enumValues();
$fields = parent::getCMSFields();
$fields->addFieldToTab('Root.Main', new Dropdownfield('GroupType', 'Group Type', $groupTypeOptions));
$fields->addFieldToTab('Root.Main', new Numericfield('NumberOfBlocks', 'Number of Blocks'));
return $fields;
}
}
If GroupType == "Standard"
I want the NumberOfBlocks
field to automatically hide so it's hidden from the user. This should happen dynamically.
Is this functionality available in SilverStripe, or do I need to add some custom JavaScript?
Display Logic
that will solve this for you: github.com/unclecheese/silverstripe-display-logic – Hooper