lekoala / ss-gridfield-utils
A collection of GridField components that you can use with any GridField, including Editable Rows and amy more
Installs: 2
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 9
Type:silverstripe-vendormodule
Requires
- php: ^7.4 || ^8
- silverstripe/framework: ^4.4 || ^5
- silverstripe/recipe-plugin: ^1 || ^2
- silverstripe/vendor-plugin: ^1 || ^2
- symbiote/silverstripe-gridfieldextensions: *
Requires (Dev)
- phpunit/phpunit: ^9.5
- squizlabs/php_codesniffer: ^3.5
Replaces
This package is auto-updated.
Last update: 2024-11-28 12:52:03 UTC
README
This module includes a subset of GridField Utilities for SilverStripe 4 and 5.
Includes the following (note they all live in the namespace LeKoala\GridFieldUtils):
- AddNewInlineExtended: A more complex version of GridFieldAddNewInlineButton, allowing you to set custom fields, rather than copying GridFieldEditableColumns (defaults to this behaviour)
- EditableRow: adds an expandable form to each row in the GridField, allowing you to edit records directly from the GridField.
- HasOneSelector: Allow you to select a has one relation from the current GridField
- AddExistingPicker: Works exactly like the one in gridfieldextensions, except it allows you to add more before closing the window - allowing for a faster workflow (requires silverstripe-australia/gridfieldextensions)
Caveats
- A deep nested EditableRow will be very slow, since it has many request handlers to access, but not much I can do about this behaviour...
Examples
HasOneSelector
$grid = new GridField('Tags', 'Tags', $this->Tags(), new GridFieldConfig); $grid->getConfig()->addComponent($component = new HasOneSelector('MainTag', 'Select main tag')); // Configure any public property... $component->showResetButton = true;
AddNewInlineExtended
$grid->getConfig()->addComponent(GridFieldButtonRow::create('before')) ->addComponent(GridFieldToolbarHeader::create()) ->addComponent(GridFieldTitleHeader::create()) ->addComponent(GridFieldEditableColumns::create()) ->addComponent(GridFieldDeleteAction::create()) ->addComponent(AddNewInlineExtended::create())
EditableRow
$grid = new GridField('Tags', 'Tags', $this->Tags(), GridFieldConfig_RecordEditor::create()); $grid->getConfig()->addComponent($component = new EditableRow());
AddExistingPicker
$grid = new GridField('Tags', 'Tags', $this->Tags(), GridFieldConfig_RelationEditor::create()); $grid->getConfig()->addComponent($component = new AddExistingPicker()); // instead of... // $grid->getConfig()->addComponent($component = new GridFieldAddExistingSearchButton()); $fields->addFieldToTab('Root.Main', $grid);
Requirements
Credits
- milkyway-multimedia: Original code
- ajshort: He did most of the coding of GridFieldExtensions, which I borrowed for the more complex versions in this module
- silverstripe-australia: They now look after the GridFieldExtensions module, and have done some updates which I have probably borrowed
License
- MIT