How to alter/sanitise widget values before they're saved?

We have a need to alter the configuration values of a widget after the user has entered them & before they're saved.

One use-case might be entering some code into a Dynamic Configuration field set to dataType=HTML.

Say we want to programatically check the HTML for a fully qualified URL, like..

<img src="">staging.blah.com/something.png">

And we want to strip off the leading domain, to leave it looking like

<img src="/something.png">

How would we go about doing a simple text replacement like that? Maybe using <propertyRule/>?

This is purely an example.. I'm after the approach we'd need to take so we could use it for things other than a URL and the Html control.

Thanks (and happy Thanksgiving to our American friends!)

Parents
  • Former Member
    0 Former Member

    It sounds like you're looking at implementing custom property rules using the IPropertyRule plugin type. The Execute method is where you can take in a value being set and manipulate it. The options on that method also expose the DataType of the property using the rule, so you can perform different logic if needed on html vs text or int fields, for example.

Reply
  • Former Member
    0 Former Member

    It sounds like you're looking at implementing custom property rules using the IPropertyRule plugin type. The Execute method is where you can take in a value being set and manipulate it. The options on that method also expose the DataType of the property using the rule, so you can perform different logic if needed on html vs text or int fields, for example.

Children