Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: Make field readonly based on another field in 5.0b

  1. #1
    dnandi is offline Member
    Join Date
    May 2008
    Posts
    5

    Default Make field readonly based on another field in 5.0b

    Hi... I am new to sugarcrm.I want to make a field read only based on another field in sugarcrm5.0.
    Any help will be greatly appreciated..... help plz.. someone.. anyone...
    Last edited by dnandi; 2008-05-05 at 10:54 AM.

  2. #2
    ptemplin7 is offline Sugar Community Member
    Join Date
    Jun 2007
    Location
    Puget Sound Washington
    Posts
    380

    Default Re: Make field readonly based on another field in 5.0b

    The best way to do this is to not add that field to the editview part of the module.
    Is that field to be edited if the other is not set.

    Another way to do this would be to set up a logic hook such that if the field is set the way that says the other should not be is to have the logic hook to blank the filed.

    Good luck,
    Paris

  3. #3
    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: Make field readonly based on another field in 5.0b

    Hi, dnandi.

    If you want to make that field readonly you can do that:
    1. Add this array inside the templateMeta of the editviewdefs.php of the module.

    PHP Code:
                                'includes'=> array(
                                                array(
    'file'=>'modules/YourModuloe/YourModule.js'),
                                             ),
                               ), 
    2. Inside the javascript you can add the code:

    document.getElementById("field_to_lock").readOnly = true;

    Based on the rule to make that field locked.

    Cheers
    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.

  4. #4
    dnandi is offline Member
    Join Date
    May 2008
    Posts
    5

    Default Re: Make field readonly based on another field in 5.0b

    Thanks a lot Andopes.
    Will give it a try. Actually i have to keep it in editview mode cause if the other field is not set, it's got 2 b edited...

  5. #5
    dnandi is offline Member
    Join Date
    May 2008
    Posts
    5

    Default Re: Make field readonly based on another field in 5.0b

    I tried it but its not working Andopes .. I think it's not calling the .js file. any suggestions...

  6. #6
    mikesolomon is offline Sugar Community Member
    Join Date
    Feb 2008
    Location
    UK
    Posts
    1,467

    Default Re: Make field readonly based on another field in 5.0b

    Quote Originally Posted by dnandi
    I tried it but its not working Andopes .. I think it's not calling the .js file. any suggestions...
    try putting an alert in the js file to see if it is being called

  7. #7
    dnandi is offline Member
    Join Date
    May 2008
    Posts
    5

    Default Re: Make field readonly based on another field in 5.0b

    I am new to sugarcrm.. Can u tell me the syntax of alert..

  8. #8
    mikesolomon is offline Sugar Community Member
    Join Date
    Feb 2008
    Location
    UK
    Posts
    1,467

    Default Re: Make field readonly based on another field in 5.0b

    Quote Originally Posted by dnandi
    I am new to sugarcrm.. Can u tell me the syntax of alert..

    The alert is just a bit of javascript - put it in the js file

    something like alert('test')

    if the js file is being called you will get a popup saying 'test'

    hope that makes sense

  9. #9
    dnandi is offline Member
    Join Date
    May 2008
    Posts
    5

    Default Re: Make field readonly based on another field in 5.0b

    Thanks. That makes complete sense.. And do u think that the above given solution by andopes will be good enough for the problem stated above...

  10. #10
    mikesolomon is offline Sugar Community Member
    Join Date
    Feb 2008
    Location
    UK
    Posts
    1,467

    Default Re: Make field readonly based on another field in 5.0b

    Quote Originally Posted by dnandi
    Thanks. That makes complete sense.. And do u think that the above given solution by andopes will be good enough for the problem stated above...
    Andre's solution looks good to me

    What he comes up with is usually great - I wish I was 1/2 as good

Page 1 of 2 12 LastLast

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 5
    Last Post: 2007-12-05, 05:43 PM
  2. Replies: 0
    Last Post: 2007-04-25, 12:45 PM
  3. Replies: 1
    Last Post: 2007-02-21, 06:32 PM
  4. How to make a field mandatory
    By nauliv in forum Help
    Replies: 3
    Last Post: 2006-11-15, 08:37 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
  •