1

I'm creating field names for electrical components and I'd like to use subscripts like this:

V<sub>min</sub>
V<sub>max</sub>
V<sub>adj</sub>

Vmin Vmax Vadj

Note that this is just for the field name, not the handle. Is there a way to do this in Craft, or a plugin that provides this functionality?

Notes:

  • Unfortunately, Unicode characters won't work in this case because the latin characters I need are not all available as subscripts in Unicode.
  • I've tried the Relabel plugin without success.
David Jones
  • 331
  • 2
  • 8

1 Answers1

2

Do you only need the HTML labels in the Control Panel? I tried it for a short time and found this solution.

Install doublesecretagency/craft-cpjs.

Add this snippet into the editor of the plugin.

var $labelReplaceElements = document.querySelectorAll('#fields th > a, #fieldlayoutform .fld-field > span, .field > .heading > label[id]');
Array.from($labelReplaceElements).forEach($element => {
    $element.innerHTML = $element.innerText;
});

You should be careful, that only admins can change fields because this solution brings an XSS risk with it.

The disadvantage is that the labels are first displayed as HTML and only after the JavaScript has been executed are they displayed correctly.

Fred
  • 166
  • 1
  • 7