protected function Classes::classElement in GridStack 8.2
Returns common class element.
2 calls to Classes::classElement()
- Classes::classesElement in src/
Plugin/ gridstack/ stylizer/ Classes.php - Classes::rowClassesElement in src/
Plugin/ gridstack/ stylizer/ Classes.php
File
- src/
Plugin/ gridstack/ stylizer/ Classes.php, line 148
Class
- Classes
- Provides the classes styles.
Namespace
Drupal\gridstack\Plugin\gridstack\stylizerCode
protected function classElement($key, $options, $refined_options, $context, $wrapper_classes = []) {
$title = str_replace([
'_',
'-',
], ' ', $key);
$value = '';
// We don't store these, fecthing from wrapper_classes string instead.
if ($wrapper_classes) {
$values = array_values($options);
$values = array_combine($values, $values);
foreach ($wrapper_classes as $wrapper_class) {
if (isset($values[$wrapper_class])) {
$value = $values[$wrapper_class];
break;
}
}
}
$css_classes = [
'form-wrapper--' . str_replace('_', '-', $key),
'is-collapsible',
'is-collapsed',
'is-gs-fieldset',
];
return [
'#type' => 'radios',
'#title' => $this
->t('@title', [
'@title' => Unicode::ucfirst($title),
]),
'#options' => [
'' => $this
->t('- None -'),
] + $refined_options,
'#default_value' => $value,
'#region' => $context,
'#is_preview' => FALSE,
'#after_build' => [
[
$this,
'afterBuildPreset',
],
],
'#group_name' => $key,
'#attributes' => [
'class' => $css_classes,
'data-gs-preset-region' => $context,
],
];
}