Make a field read-only thru code

sugarcrmdevelopers —  December 5, 2012 — 1 Comment

I was reminded from a forums post a while back on a helpful vardef definition for a field, which is also referenced in Angel Magaña blog post from a while back. The question is on how to guarantee a field is read-only for every user, which is quite common for field that derived from data outside of Sugar or are calculated on the fly. Simple add this to a new PHP file in the custom/Extension/modules/<<ModuleName>>/Ext/Vardefs/ directory…

What happens here is that the DetailView field template is rendered on the EditView and QuickCreate. This doesn’t prevent one from updating the field via code or web services however; to do that you’ll need to use the field level ACL permissions in the commerical Sugar editions to block that for a user.

One response to Make a field read-only thru code

  1. 

    Doesn’t appear to work. I am working with v6.5 CE and I have input this into my code and it has not made my custom relate field ReadOnly. I am trying to force the use of the relate Arrow, and not allow people to input stuff into the field. I put this code in and I am still able to type in the field. I closed my browser, and tried it on another machine to make sure it wasn’t a cached page.

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 )

Google+ photo

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

Connecting to %s