Using Fragment Validators Within Widget

Hi,

Does anyone know if it’s possible to use a fragment validator inside a widget? This could either be front end or backend. You can create a reference for the validators but I can’t see any way you can use them even just getting details of the fragment.

Thanks

Hi,

No, fragment validators won’t work with a custom widget. The widget will need to perform it’s own validation natively on any input fields it might contain.

You can make use of the validate() method in frontend.js, which will automatically be triggered if your widget is part of a larger widget group submission. Within here you can put your own validation code, and allows your widget to prevent form submission if any if its custom fields have any issues. But the actual validation of those input value, and the display of any errors, is up to the widget’s code to do.

What is the point of making a reference of the fragment validators then is there any way I can get information on the fragment using the CSC code?

Good question, I’m not sure there is any specific use for a Reference to a Fragment validator.

Most components can have a Reference created to them, and maybe someone has found a use for it, but I can’t think of one right now for this specific type.