guitou4573/silverstripe-pickerfield

基于GridField的管理(来自briceburg的分支)

安装: 3

依赖: 0

建议者: 0

安全: 0

星标: 0

关注者: 1

分支: 27

开放问题: 0

类型:silverstripe-module

0.9.0 2015-11-02 01:11 UTC

This package is not auto-updated.

Last update: 2024-09-21 09:51:51 UTC


README

SilverStripe 3 基于GridField管理has_one、has_many和many_many关系选择

需求

为什么?

  1. 一个高效的基于GridField的关系选择管理界面。
  2. GridField似乎不支持has_one关系。
  3. 编辑和创建所选项目的功能。

感谢SilverStripe团队和Andrew Short的GridFieldExtensions的出色工作,这个模块的开发变得容易一些。对他们表示友好。

我们所说的“高效”意味着我们需要ajax + 分页,因为我们不能将所有记录加载到下拉列表中,例如。

使用概述

屏幕截图;###概述 overview ###通过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();
 

错误

对于支持或问题,请使用GitHub提供的问题跟踪器;