Page 1 of 2 12 LastLast
Results 1 to 10 of 14
Like Tree4Likes

Thread: How to make fields read only in sugarcrm

  1. #1
    nilanjan1985 is offline Sugar Community Member
    Join Date
    Jan 2012
    Posts
    10

    Default How to make fields read only in sugarcrm

    1 .How to make the fields of case module read only?
    2.How to disable create and select button ?

  2. #2
    markriggins is offline Sugar Community Member
    Join Date
    Jan 2011
    Posts
    28

    Default Re: How to make fields read only in sugarcrm

    Quote Originally Posted by nilanjan1985 View Post
    1 .How to make the fields of case module read only?
    2.How to disable create and select button ?
    You can learn to do this all the "right" way in Sugar config files, array defs, studio settings etc. Or you can "just do it" in javascript.
    The javascript method has the added advantage that you can make some fields read-only based on the content of other fields on the same page.
    The disadvantage is that you have to add this javascript to every form that offers a chance to edit the field. Plus you have to learn how to insert javascript into the sugar edit forms, which in itself requires learning a little about sugar config files, vardefs etc.


    Code:
    /*
     * Find an object by its Id, and hide it by setting .display = 'none'
     */
    function elem_hide(id) {
        var obj = document.getElementById(id);
        if (obj != null) {
    	obj.style.display = 'none';
        }
        return obj;
    }
    
    
    /*
     * Make a form element read-only and gray it out
     */
    function elem_makeReadOnly(id) {
        var obj = document.getElementById(id);
        if (obj != null) {
            obj.readOnly = true;
    	obj.style.backgroundColor = "lightgray";
        }
        return obj;
    }

  3. #3
    nrsdnitin's Avatar
    nrsdnitin is offline Sugar Community Member
    Join Date
    Apr 2011
    Location
    Daman India
    Posts
    122

    Default Re: How to make fields read only in sugarcrm

    Dear If you want to field read only than

    goto crm=> custom => modules => Cases => metadata => editviewdefs.php


    in this if you want description read only than include js file

    'includes' =>
    array (
    0 =>
    array (
    'file' => 'readonly.js',
    ),
    ),

    'javascript' => '<script type="text/javascript"> onload=display();</script>',
    ),
    'panels' =>



    readonly.js===========>

    function display()
    {

    document.getElementById('description').disabled=tr ue;

    }
    SHI2R likes this.

  4. #4
    Fandhi Guest

    Default Re: How to make fields read only in sugarcrm

    Quote Originally Posted by nrsdnitin View Post
    Dear If you want to field read only than

    goto crm=> custom => modules => Cases => metadata => editviewdefs.php


    in this if you want description read only than include js file

    'includes' =>
    array (
    0 =>
    array (
    'file' => 'readonly.js',
    ),
    ),

    'javascript' => '<script type="text/javascript"> onload=display();</script>',
    ),
    'panels' =>



    readonly.js===========>

    function display()
    {

    document.getElementById('description').disabled=tr ue;

    }
    hi there, i know it's an old post.. but i hope someone would answer.. where do you put the readonly.js file?

  5. #5
    nrsdnitin's Avatar
    nrsdnitin is offline Sugar Community Member
    Join Date
    Apr 2011
    Location
    Daman India
    Posts
    122

    Default Re: How to make fields read only in sugarcrm

    hi,
    you can put readonly.js into sugarcrm main directoy

    e.g.: c://wamp/www/sugarcrm/readonly.js

  6. #6
    sahay143 Guest

    Post Re: How to make fields read only in sugarcrm

    Hi Nilanjan,

    Its so easy to make a field readonly.

    Suppose I want to make the name field as readonly then follow this,

    'customCode' => '<input type="text" title="" value="" maxlength="150" size="30" id="name" name="name" readonly="true">',

    Paste this items to the eidtviewdefs to your module, like

    custom/modules/Accounts/metadata/editviewdefs.php and paste the above custom code to your field(as mine is name field) as per your requirement and change the id and name accordingly.

    Thanks & Regards
    Sumit Sahay
    sumit143sweta@gmail.com
    prince likes this.

  7. #7
    NoelMayer Guest

    Default Re: How to make fields read only in sugarcrm

    The disadvantage is that you have to add this javascript to every form that offers a chance to edit the field. Plus you have to learn how to insert javascript into the sugar edit forms, which in itself requires learning a little about sugar config files, vardefs etc.

  8. #8
    preeti22 Guest

    Default Re: How to make fields read only in sugarcrm

    Quote Originally Posted by nrsdnitin View Post
    Dear If you want to field read only than

    goto crm=> custom => modules => Cases => metadata => editviewdefs.php


    in this if you want description read only than include js file

    'includes' =>
    array (
    0 =>
    array (
    'file' => 'readonly.js',
    ),
    ),

    'javascript' => '<script type="text/javascript"> onload=display();</script>',
    ),
    'panels' =>



    readonly.js===========>

    function display()
    {

    document.getElementById('description').disabled=tr ue;

    }

    Thanks for this coding, Doing excellent, i downloaded it and it works awesome, liked it thanks agian for sharing it.
    nrsdnitin likes this.

  9. #9
    saj123 Guest

    Default Re: How to make fields read only in sugarcrm

    how to make readonly field according to the user/team members login.. ??? i have installed security suite for teams and iam using sugarcrm 6.5CE

  10. #10
    nrsdnitin's Avatar
    nrsdnitin is offline Sugar Community Member
    Join Date
    Apr 2011
    Location
    Daman India
    Posts
    122

    Default Re: How to make fields read only in sugarcrm

    Quote Originally Posted by saj123 View Post
    how to make readonly field according to the user/team members login.. ??? i have installed security suite for teams and iam using sugarcrm 6.5CE
    Dear
    you can use role management in admin panel

Page 1 of 2 12 LastLast

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. how to make assigned to and created by read only
    By kasperd in forum Developer Help
    Replies: 2
    Last Post: 2009-02-19, 04:42 PM
  2. How to make a user read-only?
    By al3 in forum Help
    Replies: 2
    Last Post: 2009-02-02, 07:12 PM
  3. how to make a related field read only
    By uou in forum Developer Help
    Replies: 3
    Last Post: 2008-08-06, 07:35 AM
  4. How to make a field read only based on data
    By prismainc in forum Help
    Replies: 0
    Last Post: 2006-06-11, 02:07 PM
  5. How to make read-only custom field?
    By roberj in forum Developer Help
    Replies: 1
    Last Post: 2006-04-18, 10:48 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
  •