briceburg/silverstripe-pickerfield

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

Installs: 40 799

Dependents: 1

Suggesters: 0

Security: 0

Stars: 25

Watchers: 5

Forks: 27

Open Issues: 8

Type:silverstripe-vendormodule

0.9.0 2015-11-02 01:11 UTC

This package is not auto-updated.

Last update: 2024-12-17 02:38:39 UTC


README

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

Requirements

Why?

  1. An efficient* GridField based interface to manage relationship selections.
  2. GridField doesn't appear to natively support has_one relationships.
  3. The ability to edit and create selected items.

Thanks to the great work of the SilverStripe team and Andrew Short's GridFieldExtensions, the development of this module was a bit easier. Be kind to them.

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

Usage Overview

Screenshots; ###overview overview ###link button search [via GridFieldExtensions] link button search [via GridFieldExtensions]

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

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

}


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

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

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

// sortable field appropriate for the parent selection of a has_one relationship
$field = new HasOnePickerField($this, 'DamID', 'Selected Dam', $this->Dam(), 'Select a Dam');


// we also allow the ability to create and edit associated records via enableCreate, enableEdit methods.
$fields->addFieldsToTab('Root.Main', array(
  new HeaderField('Info','Info Blocks'),
  $field = new HasOnePickerField($this, 'AboutInfoBlockID', 'About Block', $this->AboutInfoBlock())
));
        
$field->enableCreate('Add Block')->enableEdit();
 

Bugs

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