Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » Related Data in Admin Popups

Our old forums are still available as a read-only archive.

Moderators: martimiz, Sean, biapar, Willr, Ingo, simon_w

Page: 1
Go to End
Author Topic: 1259 Views
  • fordy
    Avatar
    Community Member
    46 Posts

    Related Data in Admin Popups Link to this post

    I am trying to work out how to get related data in the popups generated from CTF's of a DataObject. For example, Players of particular team or all the applications made on a Job vacancy.

    I think it is almost like a nested CTF or the related data field but i cant find any documentation on how to use it properly.

    Does anyone know how or have any examples of how to do it???

  • fordy
    Avatar
    Community Member
    46 Posts

    Re: Related Data in Admin Popups Link to this post

    Bump

    Anyone? This is the last piece of the puzzle for me to finish this project.

  • Blackdog
    Avatar
    Community Member
    156 Posts

    Re: Related Data in Admin Popups Link to this post

    got any code to show which might help get our heads around your idea?

  • fordy
    Avatar
    Community Member
    46 Posts

    Re: Related Data in Admin Popups Link to this post

    Cheers Blackdog... I sure do,

    I have created a function that works out whether w the user is on the "list employer members" or "list candidate members" page. It then creates all the relevant fields to show the data from the table. The LEFT JOIN is required to filter by groupID.

    What I would like is to have a CTF (or similar) at the bottom of the Popup showing what vacancies the Employer has posted, and what vacancies the candidates have applied to.

    Here is my could so far:

       public function EditForm() {
          
          /*
           * Call function to find which section we are on
           * Employers or Candidates
           */
          $section = $this->Section();
          
          
          
          if($section == 'employers') {
             $title = "<h2>Employers</h2>";
             $filter = "Group_Members.GroupID = 2";
             $sort = "Member.ID Desc";
          
          }else if ($section == 'candidates'){
             
             $title = "<h2>Candidates</h2>";
             $filter = "Group_Members.GroupID = 3";
             $sort = "Member.ID Desc";
          }
          
          /*
           * Create table list fields
           */
          $fieldList = array(
             
             'FirstName' => 'First name',
             'Surname' => 'Surname',
             'Email' => 'Email',
             'Company' => 'Company',
             'City' => 'City',
             'Country' => 'Country',
             'GroupID' => "Group"
             
          );
          
          /*
           * Create Fields for Popup
           */
          $detailFields = new FieldSet();
          $detailFields->push( new TextField( 'ID', 'ID'));
        $detailFields->push( new TextField( 'FirstName', 'Firstname' ) );
        $detailFields->push( new TextField( 'Surname', 'Surname' ) );
        $detailFields->push( new TextField( 'Email', 'Position' ) );
        if($section == 'employers') {
           $detailFields->push( new TextField( 'Company', 'Company' ) );
        }
          $detailFields->push( new TextField( 'Address', 'Address Line 1' ) );
          $detailFields->push( new TextField( 'Address2', 'Address Line 2' ) );
          $detailFields->push( new TextField( 'City', 'City' ) );
          $detailFields->push( new TextField( 'ZipCode', 'Zip / Postal Code' ) );
          $detailFields->push( new TextField( 'Country', 'Country' ) );
          $detailFields->push( new TextField( 'HomePhone', 'Telephone' ) );
          $detailFields->push( new TextField( 'MobilePhone', 'Mobile Phone' ) );
          $detailFields->push( new TextField( 'NumVisit', 'Number of Visits' ) );
          $detailFields->push( new TextField( 'LastVisited', 'Last Visits' ) );
          $detailFields->push( new TextField( 'GroupID', 'Group ID' ) );
          
          /*
           * Join with Group_Members table enable filter by GroupID
           */
          $sourceJoin = "LEFT JOIN Group_Members ON Member.ID = Group_Members.MemberID";
          
          /*
           * Instantiate CTF
           */
          $tableList = new ComplexTableField($this, 'Member', 'Member', $fieldList, $detailFields, $filter,$sort, $sourceJoin );
          $tableList->setPopupCaption("Add / Edit Member");
          
          /*
           * Instantiate Fieldset for whole page with required ID for the CTF
           */
          $fields = new FieldSet(
             new HiddenField( 'ID' ),
             $tableList
          );
          
          return new Form($this, 'EditForm', $fields);
          
       }

    Thanks for your help

    1259 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.