guitou4573 / silverstripe-pickerfield
基于GridField的管理(来自briceburg的分支)
0.9.0
2015-11-02 01:11 UTC
Requires
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关系选择
需求
- SilverStripe >= 3.1
- Andrew Short的GridFieldExtensions [ https://github.com/ajshort/silverstripe-gridfieldextensions ]
为什么?
- 一个高效的基于GridField的关系选择管理界面。
- GridField似乎不支持has_one关系。
- 编辑和创建所选项目的功能。
感谢SilverStripe团队和Andrew Short的GridFieldExtensions的出色工作,这个模块的开发变得容易一些。对他们表示友好。
我们所说的“高效”意味着我们需要ajax + 分页,因为我们不能将所有记录加载到下拉列表中,例如。
使用概述
屏幕截图;###概述 ###通过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提供的问题跟踪器;