Home > Programming, Tridion > The Read-Only Fields Tridion GUI Extension

The Read-Only Fields Tridion GUI Extension


A much requested feature we at Tridion have always heard customers asking for is to be able to make component fields disabled for the end user when they are entering content.

This could be due to several reasons, one example could be that the content shouldn’t be manually typed into the field but rather be chosen from a 3rd party source (like a CRM database), for this a custom URL can be used.
A custom URL window is a neat feature in Tridion allowing the developers of the solution to build an external form/app/html page that will help the editors enter the right information into a field.

You can also think of a scenario where fields will become disabled or enabled based on the content being entered into other fields, giving the component edit form a more wizard-like feel.

The extension I created doesn’t have any such specific business logic but it does give a good basis to achieve it if needed.

The extension itself covers all types of fields; text, rich text, numeric, date, links and embedded.

Set up

To use the extension you will first need to download my jQuery extension which I introduced in a previous post: Using jQuery for Tridion GUI Extensions (the link to download is at the bottom of the article).

That article also explains how to install extensions using the TcmExtensionInstaller utility.

You’ll find the link to download the read-only extension itself at the bottom of this article.

By default the extension will look for fields that have their descriptions suffixed with “[readonly]”. I’ll discuss how you can change this to something else shortly.

Examples

Once you have set up the field(s) you want to have disabled in the schema you’re pretty much done. The extension will take care of the rest.

Here are examples of how different types of fields look like when disabled:

Text fields

Rich text fields


Unfortunately, the GUI loads these inside a frame so its much more difficult to change the background color of the text area but as you can see, the buttons on top are disabled and it is not possible to enter any text into the field.

Component link fields

Embedded fields

Depending on your screen it might be difficult to see but the extension has placed a semi-transparent overlay on top of the embedded field to make it impossible for the user to fill in any of the nested fields.

Checkboxes, radio buttons and dropdown lists

This of course also works with Metadata fields

You have probably noticed that with all these examples, the “[readonly]” text added to each of the fields’ labels has been removed by the extension.

Configuration

The extension lets you configure a few aspects using a configuration object declared at the top of the extension js file.

Label configuration

To determine which suffix string the extension will look for in the fields’ label change the ‘ReadonlyLabel’ property.

Disabled color configuration

To determine which color to paint the disabled fields, change the ‘DisabledColor’ property.

Field types configuration

You can select which types of fields to disable regardless of the suffix added to the label. This can become even more handy if you choose to add some logic of your own to the extension.

Extension Code

Can be downloaded here.

(update 26/08/2010)

The extension is also officially available on SDL Tridion World

  1. August 24, 2010 at 08:46 | #1

    LIKE!

  2. August 24, 2010 at 17:08 | #2

    Like a lot :)

  3. Pawan Khatri
    September 25, 2010 at 07:47 | #3

    Read only fields only works when you type. if you use ctrl+c and ctrl +v then you are still able to add data to read only fields in cms.

    • yoavniran
      September 27, 2010 at 12:23 | #4

      You’re absolutely right! Thanks for making me aware of this.
      I’ve fixed the code so now ctrl+v doesnt work on a disabled field.

      The downloadable file on this article updated with the fix and I will send the fix to Tridion to update the one available on TridionWorld.

      Thanks,Yoav.

  4. Dushyant Tiwari
    February 23, 2011 at 04:02 | #5

    Hi,
    I have used the same extension and find is working fine with component and not working with page & structure group metadata.
    here my question, can we extend this extension to use for page & strusture group metadata also.

    if yes, then can you please help for same.

  1. August 30, 2010 at 20:50 | #1

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

Follow

Get every new post delivered to your Inbox.

Join 302 other followers

%d bloggers like this: