Results 1 to 5 of 5

Thread: Disable field script

  1. #1
    wica is offline Sugar Community Member
    Join Date
    Jan 2008
    Location
    Vilnius, Lithuania
    Posts
    11

    Default Disable field script

    Hey,

    I've read all possibly related threads to my issue, but unfortunately i didn't find the answer.
    My problem is: I need to disable field in Opportunities module Edit View according to current user (let's say it's next step field). I've made these changes:
    1. \modules\Opportunities\views\view.edit.php - added new script:
    $disable_script=<<<EOQ
    <script>
    document.getElementsByName('next_step')[0].disabled="disabled";
    </script>
    EOQ;


    and use this code to call the script:
    global $current_user;
    $user=$current_user->user_name;
    if($user!='grazina') $this->ss->assign('DISABLE_SCRIPT', $disable_script);

    2. \modules\Opportunities\metadata\editviewdefs.php - added one line:
    'javascript' => '{$DISABLE_SCRIPT}',

    3. \cache\modules\Opportunities\EditView,tpl -- below {$PROBABILITY_SCRIPT} added one line:

    <!-- Begin Meta-Data Javascript -->
    {$PROBABILITY_SCRIPT}
    {$DISABLE_SCRIPT}


    So, everything works fine, the next step field is disabled when it's needed. But everything crashes, when I make some changes to Opportunities module via Studio. Then the line {$DISABLE_SCRIPT} disappears from \cache\modules\Opportunities\EditView.tpl (2).

    Maybe I'm doing something wrong. Any Help?

    Last edited by wica; 2008-03-04 at 10:27 AM.

  2. #2
    dpatech is offline Sugar Community Member
    Join Date
    Oct 2007
    Location
    NC
    Posts
    287

    Default Re: Disable field script

    Instead of steps two and three, add the "form" key to the editviewdefs.php metadata for Opportunities as shown below. If you have already used Studio to customize the Opportunities layout, you will need to edit the custom/modules/Opportunities/metadata/editviewdefs.php file. This will survive further Studio edits.


    PHP Code:
        'templateMeta' => array('maxColumns' => '2',
                                
    'form' => array( 'hidden'=> '{$DISABLE_SCRIPT}' ),
                                
    'widths' => array(
                                                array(
    'label' => '10''field' => '30'),
                                                array(
    'label' => '10''field' => '30')
                                                ),
        
    'javascript' => '{$PROBABILITY_SCRIPT}'
    - Sugar Team
    dpa Technology LLC
    e-mail: dpaDeveloper@dpatechnology.com
    web: http://www.dpatechnology.com

  3. #3
    wica is offline Sugar Community Member
    Join Date
    Jan 2008
    Location
    Vilnius, Lithuania
    Posts
    11

    Default Re: Disable field script

    dpatech, thanks a lot for your reply. I tried to make your suggested changes, However, after making changes via Studio to Opportunities module, these changes disappears and script doesn't work

  4. #4
    dpatech is offline Sugar Community Member
    Join Date
    Oct 2007
    Location
    NC
    Posts
    287

    Default Re: Disable field script

    I tested this out on my system and had no issues. Perhaps I didn't invoke the proper Studio functions. What exactly are you doing within Studio? Also, are you sure you modified the custom/modules/Opportunities/metadata/editviewdefs.php file and not the modules/Opportunities/metadata/editviewdefs.php
    - Sugar Team
    dpa Technology LLC
    e-mail: dpaDeveloper@dpatechnology.com
    web: http://www.dpatechnology.com

  5. #5
    wica is offline Sugar Community Member
    Join Date
    Jan 2008
    Location
    Vilnius, Lithuania
    Posts
    11

    Default Re: Disable field script

    Sorry, i've missed smth. After trying several times it works perfectly and no Studio changes affects the script.

    Thanks a lot!

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 4
    Last Post: 2007-12-10, 04:49 PM
  2. Get value of a custom field in a script?
    By sansbury in forum Developer Help
    Replies: 1
    Last Post: 2007-10-25, 07:53 AM
  3. broken links on forcast screen
    By peter.brown in forum Help
    Replies: 0
    Last Post: 2006-10-06, 07:04 AM

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
  •