Skip to content

Latest commit

 

History

History
75 lines (47 loc) · 2 KB

README.md

File metadata and controls

75 lines (47 loc) · 2 KB

silverstripe-pickerfield

SilverStripe 3 GridField based management of has_one , has_many , and many_many relationship selection

Requirements

Why?

  1. Because I needed a consistent interface to manage relationship selections in an efficient* manner.
  2. GridField doesn't appear to natively support has_one relationships.

Thanks to the great work of the SilverStripe team and Andrew Short's GridFieldExtensions, this was relatively easy to implement. Please by them beers or tea.

* by efficient we needed ajax + pagination, as we couldn't load all records into a dropdown list for instance.

Usage Overview

Screenshots;

/***********************
	Mock DataObject
************************/

class Dog extends DataObject {
	static $db = array(
		'Title'				=> 'Varchar',
		// ....
	);
	
	static $has_one = array(
		'Breeder'			=> 'Breeder'
		// ....
	);
	
	static $has_many = array(
		'Owners'	=> 'Member',
		// ....
	);
	
// ....

}


/***********************
	Field Usage
************************/

// sortable field appropriate for selection of has_many and many_many objects
$field = new PickerGridField('Owners', 'Owners', $this->Owners(), 'Select Owner(s)', 'SortOrder');

// non-sortable version of the above
$field = new PickerGridField('Owners', 'Owners', $this->Owners());

// sortable field appropriate for the parent selection of a has_one relationship
new HasOnePickerGridField($this, 'BreederID','Breeder', 'Breeder', 'Select a Breeder')

Bugs

For support or questions, please use the GitHub provided issue tracker;