Tab.php in Field Group: Easy Responsive Tabs to Accordion 8
File
src/Plugin/field_group/FieldGroupFormatter/Tab.php
View source
<?php
namespace Drupal\field_group_easy_responsive_tabs\Plugin\field_group\FieldGroupFormatter;
use Drupal\Component\Utility\Html;
use Drupal\field_group\FieldGroupFormatterBase;
class Tab extends FieldGroupFormatterBase {
public function preRender(&$element, $rendering_object) {
parent::preRender($element, $rendering_object);
$label = $this
->t($this
->getLabel());
$add = [
'#type' => 'field_group_easy_responsive_tab',
'#title' => !empty($label) ? Html::escape($label) : '',
'#description' => $this
->getSetting('description'),
'#theme_wrappers' => [
'field_group_easy_responsive_tab',
],
'#attributes' => [
'class' => $this
->getClasses(),
],
];
if (!empty($this->group->parent_name)) {
$add['#parents'] = [
$this->group->parent_name,
];
}
if ($this
->getSetting('id')) {
$add['#id'] = Html::getId($this
->getSetting('id'));
}
else {
$add['#id'] = Html::getId('edit-' . $this->group->group_name);
}
$element += $add;
}
public function settingsForm() {
$form = parent::settingsForm();
return $form;
}
public static function defaultContextSettings($context) {
$defaults = [] + parent::defaultContextSettings($context);
return $defaults;
}
}
Classes
Name |
Description |
Tab |
Plugin implementation of the 'ertta_tab' formatter. |