Please see the attached pictures. In one of my projects I have a taxonomy, which users can edit and add data. It has multiple tabs (see picture one) and each tab has multiple fields in which paragraphs can be added (see picture two).
We have different kinds of paragraphs with each different titles. Our problem is that we want to show each paragraph to the end-user (see the second picture, the button "Meting (decimaal) toevoegen") with a title of "meting" while maintaining the more descriptive titles for the admins and developers.
One option is changing the title for the end-user while maintaining the actual title in the DB. The other one would be changing the actual title in the DB and change it for the admins (setting the system name as the title).
and I've tried all kinds of hooks but can't wrap my head around this problem.
Solution: Due to the structure of the site, I couldn't get any hook solutions to work. So I wrote my own module, which attaches the javascript below to the form.
(function ($) {
'use strict';
Drupal.behaviors.test_form_styles = {
attach: function (context, settings) {
var regEx = /(?:meting)/i;
var paragraphTitles = document.getElementsByClassName("paragraph-type-title");
Object.keys(paragraphTitles).forEach(function (key) {
if (regEx.test(paragraphTitles[key].innerHTML)){
paragraphTitles[key].innerHTML = "Meting";
}
});
var submitButtons = document.getElementsByClassName("field-add-more-submit");
Object.keys(submitButtons).forEach(function (key) {
if (regEx.test(submitButtons[key].value)) {
submitButtons[key].value = "Meting toevoegen";
}
});
}
}
} (jQuery));