From aff2eda69e35607db940e5568e7c525061c97956 Mon Sep 17 00:00:00 2001 From: Ruslan-Aleev Date: Fri, 26 Jul 2024 12:07:33 +0400 Subject: [PATCH] Add an asterisk to label of required TVs --- manager/assets/modext/core/modx.js | 31 ++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/manager/assets/modext/core/modx.js b/manager/assets/modext/core/modx.js index 16845f4f421..7c19ea821c9 100644 --- a/manager/assets/modext/core/modx.js +++ b/manager/assets/modext/core/modx.js @@ -36,6 +36,7 @@ Ext.extend(MODx,Ext.Component,{ ,startup: function() { this.initQuickTips(); + this.initMarkRequiredTVs(); this.request = this.getURLParameters(); this.Ajax = this.load({ xtype: 'modx-ajax' }); Ext.override(Ext.form.Field,{ @@ -95,6 +96,36 @@ Ext.extend(MODx,Ext.Component,{ }); } + ,initMarkRequiredTVs: function() { + var markdom = '* '; + + var MarkRequiredTVPlugin = function (config) { + config = config || {}; + Ext.apply(config, { + init: function(cmp) { + if (cmp.allowBlank !== false) return; + + var id = cmp.id; + var applyTo = cmp.applyTo; + if ((id && id.match(/^tv[\d]*$/i)) || (applyTo && applyTo.match(/^tv[\d]*$/i))) { + var label = document.getElementById(id+'-caption') || document.getElementById(applyTo+'-caption'); + var html = label.innerHTML+markdom; + label.innerHTML = html; + } + } + }); + MarkRequiredTVPlugin.superclass.constructor.call(this, config); + } + Ext.extend(MarkRequiredTVPlugin, Ext.BoxComponent); + Ext.ComponentMgr.registerPlugin('markrequiredfields',MarkRequiredTVPlugin); + + if (!Array.isArray(Ext.form.Field.prototype.plugins)) { + Ext.form.Field.prototype.plugins = []; + } + var plugins = Ext.form.Field.prototype.plugins; + Ext.form.Field.prototype.plugins = Ext.form.Field.prototype.plugins.concat(['markrequiredfields'], plugins); + } + ,getURLParameters: function() { var arg = {}; var href = window.location.search;