public function YamlFormElementBase::getElementStateOptions in YAML Form 8
Get an element's supported states as options.
Return value
array An array of element states.
Overrides YamlFormElementInterface::getElementStateOptions
1 call to YamlFormElementBase::getElementStateOptions()
- YamlFormElementBase::form in src/
YamlFormElementBase.php - Gets the actual configuration form array to be built.
File
- src/
YamlFormElementBase.php, line 813
Class
- YamlFormElementBase
- Provides a base class for a form element.
Namespace
Drupal\yamlformCode
public function getElementStateOptions() {
$states = [];
// Set default states that apply to the element/container and sub elements.
$states += [
'visible' => t('Visible'),
'invisible' => t('Invisible'),
'enabled' => t('Enabled'),
'disabled' => t('Disabled'),
'required' => t('Required'),
'optional' => t('Optional'),
];
// Set element type specific states.
switch ($this
->getPluginId()) {
case 'checkbox':
$states += [
'checked' => t('Checked'),
'unchecked' => t('Unchecked'),
];
break;
case 'details':
$states += [
'expanded' => t('Expanded'),
'collapsed' => t('Collapsed'),
];
break;
}
return $states;
}