Sitecore Name Value List field with special characters

The question came up and wrote it to Sitecore StackExchange. Thank you @jammykam for your answer.

The default Sitecore Name Value List field has an annoying issue. It does not allow to use special characters like ‘-‘ for the key. I just digged into the Sitecore.Kernel library and I found a regular expression validation which is hardcoded.

Let’s overwrite this class make it more flexible. The main issue with the implementation that they don’t encode/decode the URI.

With the following class is the implementation of the new NameValueList field which allows you special characters:

To use this field you should add it to Sitecore to the following place in core database.

capture

You also need to add the following to the Sitecore config to make this field used by the Sitecore field item.

3 thoughts on “Sitecore Name Value List field with special characters

  1. It’s been a while, but this is still relevant.Thank you.

    One things to note though is that you need to provide the assembly and class when you add the item to the core DB. See https://www.codeproject.com/Tips/1069299/Extending-Sitecore-Field-Types for an example. The assembly name is just that (unlike other places where you need to put the namespace with the assembly name). And the class name is the fully qualified (with the namespace).

    Like

    1. Also, NameValue will replace your special character when the onload() method is called due to the base call (which you’ve removed completely). I didn’t want to remove that call because it does a lot of stuff upstream from Input. The way I got this to work for me was to simply make my new class detached from NameValue (so it just extends Input) and make the necessary tweaks.

      Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s