Results 1 to 3 of 3

Thread: Setting a Team in view.edit.php

  1. #1
    chrislynch8's Avatar
    chrislynch8 is offline Sugar Community Member
    Join Date
    Oct 2007
    Location
    Cork, Ireland
    Posts
    747

    Default Setting a Team in view.edit.php

    Hi,

    I am trying to set the team of a record to a certain Team always, no matter who created it. I am using the view.edit.php, I have done this before for many other modules ot inherite the Team of the Parent Record..

    I have the following code in the view.edit.php in the display function

    PHP Code:
    function display(){
    $this->ev->process;
    $query="SELECT id from teams WHERE name = 'Area 886' ";
    $res=$this->bean->db->query($query);
    $row=$this->bean->db->fetchByAssoc($res);
    If(!empty(
    $row)){
    $this->ev->fieldDefs['team_id']['value'] = $row['id'];
    $this->ev->fieldDefs['team_set_id']['value'] = $row['id'];
    }
    parent::display();

    I have echoed the ID of the Team that is selected in the Query and it is correct, I have also Echoed $this->ev->fieldDefs['team_id']['value'] and the Team_Set_id after setting them and they are both correct.

    But when I create/edit a record the Team is not set and it is going to the users default team. Any one noticed an issue with the code?

    Rgds
    Chris
    Linkedin Profile:Chris Lynch

    FDC IT Solutions
    FDC House
    Wellington Road
    Cork
    Ireland

  2. #2
    eggsurplus's Avatar
    eggsurplus is offline Sugar Community Member
    Join Date
    Dec 2005
    Location
    Minnesota
    Posts
    2,343

    Default Re: Setting a Team in view.edit.php

    My guess is that you'd need to do it in a before_save or after_save hook instead of before loading the edit screen. There may be logic processing during the save that is overriding your preference.

  3. #3
    chrislynch8's Avatar
    chrislynch8 is offline Sugar Community Member
    Join Date
    Oct 2007
    Location
    Cork, Ireland
    Posts
    747

    Default Re: Setting a Team in view.edit.php

    Hi,

    I found that if I remove the parent::display() and include echo $this->ev->display() it works

    Rgds
    Chris
    Linkedin Profile:Chris Lynch

    FDC IT Solutions
    FDC House
    Wellington Road
    Cork
    Ireland

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-02-04, 01:40 PM
  2. Edit View to detail view to edit view
    By nanduruchi in forum Developer Help
    Replies: 0
    Last Post: 2010-08-21, 06:52 AM
  3. Replies: 13
    Last Post: 2007-10-04, 05:53 AM
  4. Replies: 5
    Last Post: 2007-05-21, 12:59 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
  •