Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Archive /

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

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

Related Data in Admin Popups


Go to End


4 Posts   1584 Views

Avatar
fordy

Community Member, 46 Posts

28 April 2008 at 7:26am

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???

Avatar
fordy

Community Member, 46 Posts

29 April 2008 at 7:26am

Bump :-(

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

Avatar
Blackdog

Community Member, 156 Posts

29 April 2008 at 3:41pm

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

Avatar
fordy

Community Member, 46 Posts

29 April 2008 at 8:12pm

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 :-)