From 41c27089c7373bfdd330250f4ba1c1338df0003c Mon Sep 17 00:00:00 2001 From: Ivan Bochkarev Date: Wed, 25 Feb 2026 09:02:02 +0600 Subject: [PATCH] fix(manager): remove URI maxLength and show URI field on validation errors (#13815) - Remove maxLength from URI field in resource panel and tree quick update - Override failure to reveal URI field when server returns uri errors - In failureSubmit, reveal URI field when client validation fails on uri - Add revealUriField() and hasUriError() for clarity and reuse --- .../widgets/resource/modx.panel.resource.js | 32 +++++++++++++++++-- .../widgets/resource/modx.tree.resource.js | 1 - 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/manager/assets/modext/widgets/resource/modx.panel.resource.js b/manager/assets/modext/widgets/resource/modx.panel.resource.js index 5d2f9c7d523..61aed492fc7 100644 --- a/manager/assets/modext/widgets/resource/modx.panel.resource.js +++ b/manager/assets/modext/widgets/resource/modx.panel.resource.js @@ -26,7 +26,11 @@ MODx.panel.Resource = function(config) { ,fieldChange: {fn:this.onFieldChange,scope:this} ,failureSubmit: { fn: function () { - this.showErroredTab(this.errorHandlingTabs, 'modx-resource-tabs') + var uriField = this.getForm().findField('uri'); + if (uriField && !uriField.isValid()) { + this.revealUriField(); + } + this.showErroredTab(this.errorHandlingTabs, 'modx-resource-tabs'); }, scope: this } @@ -275,6 +279,31 @@ Ext.extend(MODx.panel.Resource,MODx.FormPanel,{ } } + ,revealUriField: function() { + var urio = Ext.getCmp('modx-resource-uri-override'); + var uri = Ext.getCmp('modx-resource-uri'); + if (urio && uri) { + urio.setValue(true); + uri.show(); + } + } + + ,failure: function(o) { + var errors = o && o.result && o.result.errors; + if (this.hasUriError(errors)) { + this.revealUriField(); + } + MODx.panel.Resource.superclass.failure.call(this, o); + } + + ,hasUriError: function(errors) { + if (!errors) { return false; } + if (Array.isArray(errors)) { + return errors.some(function(e) { return e && e.id === 'uri'; }); + } + return !!errors.uri; + } + // used for realtime-alias transliteration ,translitAlias: function(string) { if (!this.config.translitloading) { @@ -1002,7 +1031,6 @@ Ext.extend(MODx.panel.Resource,MODx.FormPanel,{ ,description: '[[*uri]]
'+_('resource_uri_help') ,name: 'uri' ,id: 'modx-resource-uri' - ,maxLength: 255 ,value: config.record.uri || '' ,hidden: !config.record.uri_override }]; diff --git a/manager/assets/modext/widgets/resource/modx.tree.resource.js b/manager/assets/modext/widgets/resource/modx.tree.resource.js index a1f2265859d..c644a2140c4 100644 --- a/manager/assets/modext/widgets/resource/modx.tree.resource.js +++ b/manager/assets/modext/widgets/resource/modx.tree.resource.js @@ -1448,7 +1448,6 @@ MODx.getQuickCreateResourceSettingsFields = function(id, parentData) { description: `[[*uri]]
${_('resource_uri_help')}`, name: 'uri', id: `modx-${id}-uri`, - maxLength: 255, anchor: '100%', value: parentData.uri || '', hidden: !parentData.uri_override