Results 1 to 5 of 5

Thread: Best way to disable a field in edit view?

  1. #1
    msuser is offline Member
    Join Date
    Jun 2011
    Posts
    7

    Default Best way to disable a field in edit view?

    In the edit view of an opportunity how would you disable (grey out) a particular text field based on a value for that opportunitity?

    im guessing i'd have to put some code in a logic hook (which one?) to disable to form field based on this value but i dont knwo where to begin. most of the similar questions i've seen have been javascript based since they were the result of something clicking a drop down or something, where as mine would be PHP based.

  2. #2
    letrium is offline Sugar Community Member
    Join Date
    Dec 2008
    Posts
    614

    Default Re: Best way to disable a field in edit view?

    MODULE_NAME/metadata/editviewdefs.php (better to put it to custom folder to make it be upgrade-safe)

    PHP Code:
    'PARENT_FIELD_NAME' => array(
              
    'name' => 'PARENT_FIELD_NAME',
                
    'displayParams' => 
                array (
                  
    'javascript' => onchange="if(this.value == \'1\' ) {document.EditView.CHILD_FIELD_NAME.disabled =\'disabled\' }else{document.EditView.CHILD_FIELD_NAME.disabled = \'\'}",
                ),
    ), 
    Last edited by letrium; 2011-07-06 at 05:38 AM.

  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: Best way to disable a field in edit view?

    This can be easily accomplished by DevToolKit.
    You can find the link to project page at my signature.

    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.

  4. #4
    msuser is offline Member
    Join Date
    Jun 2011
    Posts
    7

    Default Re: Best way to disable a field in edit view?

    Quote Originally Posted by letrium View Post
    MODULE_NAME/metadata/editviewdefs.php (better to put it to custom folder to make it be upgrade-safe)

    PHP Code:
    'PARENT_FIELD_NAME' => array(
              
    'name' => 'PARENT_FIELD_NAME',
                
    'displayParams' => 
                array (
                  
    'javascript' => onchange="if(this.value == \'1\' ) {document.EditView.CHILD_FIELD_NAME.disabled =\'disabled\' }else{document.EditView.CHILD_FIELD_NAME.disabled = \'\'}",
                ),
    ), 
    hmmm i would have though i don't need to use javascript since all i want is when you go to the edit screen i want to disable the "name" of the opportunitiy and the "account name" of the opportunitity is a value of that bean is set to 1 (or whatever). i tried this, doesn't seem to work.

    and i can't install a custom dev kit on this version unfortunately, not allowed to.

  5. #5
    letrium is offline Sugar Community Member
    Join Date
    Dec 2008
    Posts
    614

    Default Re: Best way to disable a field in edit view?

    PHP Code:
    'FIELD_NAME' => array(
      
    'name' => 'FIELD_NAME',
      
    'customCode' => '
          {if $fields.SOME_FIELD.value}
              <input type="text" name="FIELD_NAME" value= "{$fields.FIELD_NAME.value}">
          {/else}
                {$fields.FIELD_NAME.value}
           {/if}
      '
    ), 

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 2
    Last Post: 2011-06-21, 01:34 PM
  2. Have to disable Edit button in Detail View of Cases module
    By naveenshurpalekar in forum Developer Help
    Replies: 5
    Last Post: 2009-11-19, 12:36 PM
  3. Disable custom fields in edit view
    By detour in forum Help
    Replies: 6
    Last Post: 2009-05-13, 04:22 PM
  4. How to disable the field in search view
    By vsaranya in forum Developer Help
    Replies: 6
    Last Post: 2008-08-13, 01:22 PM
  5. Replies: 1
    Last Post: 2007-03-02, 06:14 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
  •