bratiask / silverstripe-pickerfield
基于GridField的has_one、has_many和many_many关系选择管理
5.0.0
2023-12-21 12:42 UTC
Requires
This package is not auto-updated.
Last update: 2024-09-26 16:10:44 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提供的问题跟踪器;