Results 1 to 10 of 10

Thread: How to set a field to read only

  1. #1
    npolite is offline Sugar Community Member
    Join Date
    May 2008
    Posts
    20

    Default How to set a field to read only

    Hello,

    I'm trying to get a field in the Sugar customer portal to display as read only. Here is the code that I have from the editviewdefs.php under the Cases module.

    8 =>
    array (
    0 =>
    array (
    'displayParams' =>
    array ('rows' => '15',
    'cols' => '110',
    ),
    'label' => 'Resolution',
    'field' => 'resolution_c',
    ),
    ),

    Can someone help me out with what I need to add to make it read only?

    Thanks,
    Nick

  2. #2
    SugarDev.net is offline Sugar Community Member
    Join Date
    Feb 2008
    Posts
    1,401

    Default Re: How to set a field to read only

    First, please place your code in [ php ] [ /php ] tags for readability

    PHP Code:
    =>
      array (
      
    => array (
        
    'displayParams' => array (
          
    'rows' => '15',
          
    'cols' => '110',
          
    'readOnly' => true
        
    ),
        
    'label' => 'Resolution',
        
    'field' => 'resolution_c'
      
    ),
    ), 
    BTW, this is perfectly documented in the wiki: http://www.sugarcrm.com/wiki/index.php?title=Model-View-Controller_(MVC)
    Developers go here
    Businesses go there (Dutch)

    Modules:
    SugarDev.net Developer Tools | Config | Dutch Language Pack
    "Nothing gets fixed unless there is a bug"

  3. #3
    dlorenzetti's Avatar
    dlorenzetti is offline Sugar Community Member
    Join Date
    Jan 2008
    Location
    São Paulo, Brasil
    Posts
    189

    Default Re: How to set a field to read only

    Hi Nick,

    try put 'type' => 'readonly' how below


    8 =>
    array (
    0 =>
    array (
    'type' => 'readonly',
    'displayParams' =>
    array ('rows' => '15',
    'cols' => '110',
    ),
    'label' => 'Resolution',
    'field' => 'resolution_c',
    ),
    ),


    But that way Sugar don't build the <input>, just show the value, like detail view, for build the <input> you can use customCode and build it yourself.


    I hope this help.
    Diego Lorenzetti
    Lampada Global Services - Open Source Solutions
    Phone: +55 11 3237-3110
    Email: equipe@lampadaglobal.com
    Site: www.lampadaglobal.com

    Lampada Global delivers offshore software development and support services to customers around the world.
    Lampada is proud to be a SugarCRM Gold Partner, revolutionizing Customer Relationship Management.

  4. #4
    sugarcane is offline Sugar Community Member
    Join Date
    Apr 2005
    Location
    Chicago, IL
    Posts
    1,207

    Default Re: How to set a field to read only

    Another simple option would be to just place the field in the detial view and not the edit view
    Intelestream has a great deal of experience hosting and customizing the SugarCRM application. Our company is made up by former employees of SugarCRM, and together we have over 50 years of experience working with the application. To learn more about us, please visit our website at www.intelestream.net or contact us directly at 800-391-4055 or by email at info@intelestream.net

  5. #5
    npolite is offline Sugar Community Member
    Join Date
    May 2008
    Posts
    20

    Default Re: How to set a field to read only

    Hi,

    I tried the first two suggestions and they didn't seem to work.


    Thanks,
    Nick

  6. #6
    npolite is offline Sugar Community Member
    Join Date
    May 2008
    Posts
    20

    Default Re: How to set a field to read only

    Does anyone else have any suggestions I can try?

    Thanks,
    Nick

  7. #7
    andopes's Avatar
    andopes is offline A Sugar Hero | Help Forum Moderator
    Join Date
    Jul 2006
    Location
    São Paulo - Brazil
    Posts
    8,335

    Default Re: How to set a field to read only

    Hi Nick

    Only dropdown and relate fields support readOnly displayParams.
    You can create a customCode to perform this action.
    I hope SugarCRM add this feature to all field templates.

    Regards
    André Lopes
    DevToolKit / Project of the Month - June 2009
    Lampada Global Services- Open Source Solutions
    Avenida Ipiranga, 318
    Bloco B - CJ 1602
    São Paulo, SP 01046-010
    Brazil
    Office: +55 11 3237-3110
    Mobile: +55 11 7636-5859
    e-mail: andre@lampadaglobal.com

    Lampada Global delivers offshore software development and support services to customers around the world.
    Lampada is proud to be a SugarCRM Gold Partner, revolutionizing Customer Relationship Management.

    I DO NOT answer questions through PM and Email. If you need some help post your question into SugarForum.

  8. #8
    danheff is offline Senior Member
    Join Date
    Aug 2008
    Posts
    90

    Default Re: How to set a field to read only

    I found this in another post, but I just added an extra line under the applicable array in editviewdefs.php for the module.

    In my case, I went to custom/modules/Opportunities/metadata and opened up editviewdefs.php

    I added

    'type' => 'readonly',

    after

    array {
    'name' => '(whatever)',
    'label' => '(whatever)',

    Periodically, however, it reverts back to a non-read-only field...when I check the editviewdefs.php file, the extra line I added is gone. I'm not exactly sure what causes this, perhaps any editing of the module within Studio erases this custom change, but its easy to put back.

  9. #9
    eggsurplus's Avatar
    eggsurplus is offline Sugar Community Member
    Join Date
    Dec 2005
    Location
    Minnesota
    Posts
    2,343

    Default Re: How to set a field to read only

    Dan,

    You're right on. When you make a change in Studio it'll overwrite the file and your changes. A little frustrating but it can be worked around.

  10. #10
    rgtft is offline Senior Member
    Join Date
    Nov 2008
    Location
    East Lansing, MI
    Posts
    41

    Default Re: How to set a field to read only

    Quote Originally Posted by danheff View Post
    I found this in another post, but I just added an extra line under the applicable array in editviewdefs.php for the module.

    In my case, I went to custom/modules/Opportunities/metadata and opened up editviewdefs.php

    I added

    'type' => 'readonly',

    after

    array {
    'name' => '(whatever)',
    'label' => '(whatever)',

    Periodically, however, it reverts back to a non-read-only field...when I check the editviewdefs.php file, the extra line I added is gone. I'm not exactly sure what causes this, perhaps any editing of the module within Studio erases this custom change, but its easy to put back.
    I did everything as above to my custom/modules/Contacts/metadata/editviewdefs.php and everything worked fine, but the changes did not seem to take effect until I went to the Admin menu and did the Repair/Rebuild processes.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Set the default value of a standard field
    By pbperche in forum General Discussion
    Replies: 8
    Last Post: 2009-01-14, 08:37 PM
  2. Adding Autonumber Field
    By phillipdean in forum Developer Help
    Replies: 2
    Last Post: 2008-12-07, 03:11 AM
  3. Setting priority field for a case via SOAP
    By egon1024 in forum Developer Help
    Replies: 2
    Last Post: 2008-02-13, 06:44 PM
  4. Replies: 4
    Last Post: 2007-12-10, 04:49 PM
  5. How to make a field read only based on data
    By prismainc in forum Help
    Replies: 0
    Last Post: 2006-06-11, 01:07 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •