\GridFieldLimitItems
Simple component which enables you to easily limit the maximum number of items that are setup in a relation that is being managed by a GridField instance.
- Author: Patrick Nelson, pat@catchyour.com
Synopsis
class GridFieldLimitItems
implements
GridField_HTMLProvider,GridField_DataManipulator
{
- // members
- protected $maxItems;
- protected bool $removeButton = true;
- protected string $noteLocation = 'before';
- protected bool $removeFromTop = false;
- protected callable $onBeforeManipulate;
- protected callable $onAfterManipulate;
- // methods
- public void __construct()
- public void setMaxItems()
- public void setRemoveButton()
- public GridFieldLimitItems setNoteAbove()
- public GridFieldLimitItems setNoteBelow()
- public GridFieldLimitItems setRemoveFromTop()
- public GridFieldLimitItems onBeforeManipulate()
- public GridFieldLimitItems onAfterManipulate()
- public array getHTMLFragments()
- public DataList|SS_List getManipulatedData()
- protected void debug()
Hierarchy
Implements
- GridField_HTMLProvider
- GridField_DataManipulator
Members
protected
Methods
protected
- debug() — For internal debug use only.
public
- __construct()
- getHTMLFragments() — Generates HTML responsible for note above/below the grid field.
- getManipulatedData() — Manipulate the {@link DataList} as needed by this grid modifier.
- onAfterManipulate() — Allows you to perform some sort of action AFTER any sort of manipulation is performed.
- onBeforeManipulate() — Allows you to perform some sort of action BEFORE any sort of manipulation is performed.
- setMaxItems() — The maximum number of items you wish to allow in this grid field.
- setNoteAbove() — Indicate the position of the note. Either above or below the grid field.
- setNoteBelow() — Indicate the position of the note. Either above or below the grid field.
- setRemoveButton() — Indicates that the 'Add New [x]' button should be removed once we reach our limit.
- setRemoveFromTop() — By default, items are removed from the bottom of the list, but this allows you to configure it to remove from the top instead.