diff --git a/cdesai_tff.module b/cdesai_tff.module new file mode 100644 index 0000000..5dd0a14 --- /dev/null +++ b/cdesai_tff.module @@ -0,0 +1,30 @@ + [ + 'template' => 'cdesai-tff-tooltip-formatter', + 'variables' => [ + 'value' => NULL, + 'attributes' => [], + ], + ], + ]; +} + +/** + * Preprocessor for cdesai_tff_tooltip_formatter theme. + */ +function template_preprocess_cdesai_tff_tooltip_formatter(&$variables) { + //$attributes = new Attribute($variables['attributes']); +} diff --git a/src/Plugin/Field/FieldFormatter/TooltipTextFormatter.php b/src/Plugin/Field/FieldFormatter/TooltipTextFormatter.php new file mode 100644 index 0000000..9a6b58f --- /dev/null +++ b/src/Plugin/Field/FieldFormatter/TooltipTextFormatter.php @@ -0,0 +1,57 @@ + $item) { + $elements[$delta] = [ + '#theme' => 'cdesai_tff_tooltip_formatter', + '#value' => $this->getValue($item), + '#attributes' => [ + 'class' => [$this->getCssClassId()], + ], + ]; + } + + return $elements; + } + + /** + * @inheritDoc + */ + function getValue(FieldItemInterface $item) { + return $item->getString(); + } + +} + diff --git a/templates/cdesai-tff-tooltip-formatter.html.twig b/templates/cdesai-tff-tooltip-formatter.html.twig new file mode 100644 index 0000000..ec19505 --- /dev/null +++ b/templates/cdesai-tff-tooltip-formatter.html.twig @@ -0,0 +1,3 @@ + + {{ value }} +