Results 1 to 4 of 4

Thread: enable field based on username?

  1. #1
    blitz2190 is offline Senior Member
    Join Date
    Jul 2009
    Posts
    105

    Default enable field based on username?

    i have a field that is disabled with javascript onload now i need it to be enable if the current user is the assigned user's manager which come from the "Report to" in user profile, now i can get the Reports to name and the current user but i can not enable it with a logic hook because the logic hook fires before the field is created any ideas

  2. #2
    christianknoll's Avatar
    christianknoll is offline Sugar Community Member
    Join Date
    Nov 2008
    Location
    Vienna
    Posts
    939

    Default Re: enable field based on username?

    make a hiddenf ield in the form with users managers ID which you poplate on load in the beanand submit to the smarty Template and then also the users ID (same way) and enable it with JS which you also embed in the form which reads the resp. fields by their IDs and then enables the field if appropriate

    Easy task ... christian.

    Quote Originally Posted by blitz2190 View Post
    i have a field that is disabled with javascript onload now i need it to be enable if the current user is the assigned user's manager which come from the "Report to" in user profile, now i can get the Reports to name and the current user but i can not enable it with a logic hook because the logic hook fires before the field is created any ideas

  3. #3
    blitz2190 is offline Senior Member
    Join Date
    Jul 2009
    Posts
    105

    Default Re: enable field based on username?

    i am able to get the user's manager id from sql but is there a smarty or bean that will enable me to do this

  4. #4
    blitz2190 is offline Senior Member
    Join Date
    Jul 2009
    Posts
    105

    Default Re: enable field based on username?

    i put this in editviewdefs.php

    PHP Code:
    'javascript' => '<script>
    window.onload=function() 
    {literal} { {/literal}
        var supervisor_id = <?php echo $manager ?>;
        var curr_user = <?php echo $current_id ?>;
        if(supervisor_username != curr_user) 
        {literal} { {/literal}
               document.getElementById(\'status\').disabled=true;
        {literal} } {/literal}
    {literal} } {/literal}
      </script>'
    and this at the top
    PHP Code:
    global $current_user;
    $current_id=$current_user->id;
    $manager=$bean->managers_id_c
    but the php variables are not transfering there value any i dea why

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 0
    Last Post: 2009-07-22, 11:42 AM
  2. Replies: 2
    Last Post: 2009-04-09, 10:50 AM
  3. How to enable field that references the users dropdown
    By blipper2000 in forum Developer Help
    Replies: 0
    Last Post: 2007-05-11, 07:21 PM
  4. Replies: 0
    Last Post: 2007-04-25, 12:45 PM
  5. How to enable inline lookup for a given field?
    By zoobee in forum Developer Help
    Replies: 0
    Last Post: 2006-06-30, 03:03 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
  •