lekoala/ss-gridfield-utils

A collection of GridField components that you can use with any GridField, including Editable Rows and amy more

Installs: 1

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 9

Type:silverstripe-vendormodule

dev-master 2024-11-12 23:15 UTC

This package is auto-updated.

Last update: 2024-11-15 14:09: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