Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.
SOLVED

CQ5.6 xtype:pathfield regex "Uncaught TypeError"

Avatar

Level 1

Hi there, I'm using the CQ5.6.1 and try to create a component config dialog with a "pathfield" item,

I configured "regex" & "regexText" for this pathfield for the validation purpose, however when I saved code change

and tried to update&save this pathfield, I got a JS error "Uncaught TypeError: undefined is not a function".

Then I checked the JS source code, seems related with the following code section from libs/cq/ui/widgets.min.js:

-----------------------------

        if (this.regex && !this.regex.test(a)) {
            g.push(this.regexText)
        }
        return g

-----------------------------

  With the debug info I found the regex is String instead of RegExp object, so caused ".test" method with "undefined" error.

It should be a defect, please take a look and give a fix patch for the later release.

Regards.

1 Accepted Solution

Avatar

Correct answer by
Level 10

regexText would be String for everything apart from xtype:textfield in extJS

I found this to customize the validate method here. please check if this helps [1]

[1] http://stackoverflow.com/questions/26974184/cq-custom-widget-for-text-link-checkbox-in-multifield

View solution in original post

3 Replies

Avatar

Correct answer by
Level 10

regexText would be String for everything apart from xtype:textfield in extJS

I found this to customize the validate method here. please check if this helps [1]

[1] http://stackoverflow.com/questions/26974184/cq-custom-widget-for-text-link-checkbox-in-multifield

Avatar

Level 10

In your regular expression you might be missing slash.  Validate your expression.

Avatar

Level 1

I do added "/" at the start and end of the regex, seems the problem is regex is parsed as String instead of RegExp object.