Sitecore renames my field’s title

Have you ever seen an odd issue where your field title is different from the one you defined on your template even if you didn’t set any Display Name value? Well, here I will explain how you can come across with this issue and how you can resolve it.

Take a look at the sample item that comes with a new Sitecore instance:  /sitecore/templates/Sample/Sample Item

2017-04-06 17_24_34-Desktop

And now let’s see the __Standard Values item, which basically has a Title (with a token $name) and Text.

2017-04-06 17_41_46-Desktop.png

Now, I want to reproduce the “issue” I’m talking about; Let’s create a dictionary entry (/sitecore/templates/System/Dictionary/Dictionary entry), under the system dictionary, /sitecore/system/Dictionary.

2017-04-06 17_26_28-Desktop

If you take a look closely, you will notice that the key has the same value as one of our fields in the Sample item template.

Mysteriously, the title of our field has changed!!

2017-04-06 17_25_18-Desktop

The title of the Text field changed to “This is the text”. My first impression when this thing happened to me is that the Display name has been set, but if we look at that field, we don’t have any value in there.

2017-04-06 17_25_56-Desktop

When Sitecore loads the template content editor, it calls to the EditorFormatter which is the responsible for rendering the form. It includes buttons, sections and fields.

When it render each field, there is method that renders the field title:

title = (field.TemplateField.IgnoreDictionaryTranslations ? itemField.Name : Translate.Text(itemField.Name));

 

In this case, it’s triggering the Translate.Text(“Text”) which results “This is the text”.

If we don’t want to use any dictionary entry than can replace the field title, we can enable the Ignore Dictionary Translations inside the Data section of each field.

2017-04-06 18_41_55-Desktop

Then you will see the correct field title.

The bottom line of this post, and this is a personal opinion, is don’t use the default dictionary that comes out of the box in the System. It’s a recommended practice to create your own dictionary node which will host dictionary folders and entries.

2017-04-06 17_27_10-Desktop

In that way, your fields’ title will be safe and you won’t see this issue anymore. Don’t forget to add the dictionary domain attribute into your site definition

<site="mywebsite" ...... dictionaryDomain="MY_DICTIONARY_ID" />

 

If you prefer to use patch files, then use this config:

<?xml version="1.0"?>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
  <sitecore>
    <sites>
      <site name="mywebsite">
        <patch:attribute name="dictionaryDomain">MY_DICTIONARY_ID</patch:attribute>
      </site>
    </sites>
  </sitecore>
</configuration>

 

You can use the item path if you like.

I hope you enjoyed this post and don’t forget to share it.

Happy Sitecoring 😉

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 )

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