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.
  • I don't think it's possible to use HTML (or Markdown) in the field name. – Lindsey D Jul 13 at 4:06
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.

  • Yep, I only need it in the control panel. This is exactly what I was looking for. Thanks! – David Jones Jul 14 at 0:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.