webbuilders-group / silverstripe-limitedrelationsgridfield
Adds the ability to limit the number of items in the relationship managed by GridField.
Installs: 1 612
Dependents: 0
Suggesters: 0
Security: 0
Stars: 4
Watchers: 5
Forks: 4
Open Issues: 0
Type:silverstripe-vendormodule
Requires
- composer/installers: *
- silverstripe/framework: ~4.2|~5.0
README
Adds the ability to limit the number of items in the relationship managed by GridField.
Maintainer Contact
- Ed Chipman (UndefinedOffset)
Requirements
- SilverStripe CMS 4.2+
Installation
Composer (recommended):
composer require webbuilders-group/silverstripe-limitedrelationsgridfield
Usage
For many_many relationships simply swap the configuration for the GridField with LRGridFieldConfig_RelationEditor, for example.
//Create a GridField instance with a page length of 10 and a item cound limit of 20 new GridField('MyGridField', 'My GridField', $this->Relationship(), LRGridFieldConfig_RelationEditor::create(10, 20));
For has_many relationships simply swap the configuration for the GridField with LRGridFieldConfig_RecordEditor, for example.
//Create a GridField instance with a page length of 10 and a item cound limit of 20 new GridField('MyGridField', 'My GridField', $this->Relationship(), LRGridFieldConfig_RecordEditor::create(10, 20));
Configuration Options
The LRGridFieldAddExistingAutocompleter component provides a single method that allows changing of the limit, as well this limit can be set as the 3rd parameter to the constructor.
$myLimitedAutoCompleter->setItemLimit(3); //Change the item limit to 3
The LRGridFieldDetailForm component provides a single method that allows changing of the limit, as well this limit can be set as the 2nd parameter to the constructor.
$myLimitedDetailForm->setItemLimit(3); //Change the item limit to 3