Skip to content

Commit

Permalink
Add an asterisk to label of required TVs
Browse files Browse the repository at this point in the history
  • Loading branch information
Ruslan-Aleev committed Jul 26, 2024
1 parent a296ee3 commit aff2eda
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions manager/assets/modext/core/modx.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,{
Expand Down Expand Up @@ -95,6 +96,36 @@ Ext.extend(MODx,Ext.Component,{
});
}

,initMarkRequiredTVs: function() {
var markdom = '<span class=\"required\">*</span> ';

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;
Expand Down

0 comments on commit aff2eda

Please sign in to comment.