GridFieldNestedForm
class GridFieldNestedForm extends AbstractGridFieldComponent implements GridField_URLHandler, GridField_ColumnProvider, GridField_SaveHandler, GridField_HTMLProvider, GridField_DataManipulator (View source)
Gridfield component for nesting GridFields
Traits
Provides extensions to this object to integrate it with standard config API methods.
A trait that makes a class able to consume and use a GridFieldStateManagerInterface implementation
A class that can be instantiated or replaced via DI
Constants
POST_KEY |
The key used in the post data to identify nested form data |
Config options
allowed_actions | |||
default_max_nesting_level | int | The default max nesting level. Nesting further than this will throw an exception. |
Properties
protected | GridFieldStateManagerInterface | $stateManager | from GridFieldStateAware |
Methods
An implementation of the factory method, allows you to create an instance of a class
Creates a class instance by the "singleton" design pattern.
Get a configuration accessor for this class. Short hand for Config::inst()->get($this->class, .....).
Gets the uninherited value for the given config option
Fallback on the direct Injector access, but allow a custom implementation to be applied
Set the relation name to use for the nested grid fields
Set whether the nested grid fields should be inline editable
Set whether the nested grid fields should be expanded by default
Set whether the nested grid fields should be forced closed on load
Set a callback function to check which items in this grid that should show the expand link for nested gridfields. The callback should return a boolean value.
Set the maximum nesting level allowed for nested grid fields
Additional metadata about the column which can be used by other components, e.g. to set a title for a search column header.
Attributes for the element containing the content returned by getColumnContent().
Modify the list of columns displayed in the table.
HTML for the column, content of the
Return URLs to be handled by this grid field, in an array the same form as $url_handlers.
Returns a map where the keys are fragment names and the values are pieces of HTML to add to these fragments.
Handle the request to show a nested item
Handle the request to toggle a nested item in the gridfield state
Called when a grid field is saved - i.e. the form is submitted.
Manipulate the SS_List as needed by this grid modifier.
Details
static Injectable
create(mixed ...$args)
An implementation of the factory method, allows you to create an instance of a class
This method will defer class substitution to the Injector API, which can be customised via the Config API to declare substitution classes.
This can be called in one of two ways - either calling via the class directly, or calling on Object and passing the class name as the first parameter. The following are equivalent: $list = DataList::create(SiteTree::class); $list = SiteTree::get();
static Injectable
singleton(string $class = null)
Creates a class instance by the "singleton" design pattern.
It will always return the same instance for this class, which can be used for performance reasons and as a simple way to access instance methods which don't rely on instance data (e.g. the custom SilverStripe static handling).
static Config_ForClass
config()
Get a configuration accessor for this class. Short hand for Config::inst()->get($this->class, .....).
mixed
uninherited(string $name)
Gets the uninherited value for the given config option
GridFieldStateAware
setStateManager(GridFieldStateManagerInterface $manager)
No description
GridFieldStateManagerInterface
getStateManager()
Fallback on the direct Injector access, but allow a custom implementation to be applied
__construct($name = 'NestedForm')
No description
GridField
getGridField()
Get the grid field that this component is attached to
string
getRelationName()
Get the relation name to use for the nested grid fields
GridFieldNestedForm
setRelationName(string $relationName)
Set the relation name to use for the nested grid fields
bool
getInlineEditable()
Get whether the nested grid fields should be inline editable
GridFieldNestedForm
setInlineEditable(bool $editable)
Set whether the nested grid fields should be inline editable
GridFieldNestedForm
setExpandNested(bool $expandNested)
Set whether the nested grid fields should be expanded by default
GridFieldNestedForm
setForceClosedNested(bool $forceClosed)
Set whether the nested grid fields should be forced closed on load
GridFieldNestedForm
setCanExpandCallback(callable|string $callback)
Set a callback function to check which items in this grid that should show the expand link for nested gridfields. The callback should return a boolean value.
You can either pass a callable or a method name as a string.
GridFieldNestedForm
setMaxNestingLevel(int $level)
Set the maximum nesting level allowed for nested grid fields
int
getMaxNestingLevel()
Get the max nesting level allowed for this grid field.
protected bool
atMaxNestingLevel(GridField $gridField)
Check if we are currently at the max nesting level allowed.
array
getColumnMetadata(GridField $gridField, string $columnName)
Additional metadata about the column which can be used by other components, e.g. to set a title for a search column header.
array
getColumnsHandled(GridField $gridField)
Names of all columns which are affected by this component.
array
getColumnAttributes(GridField $gridField, ViewableData $record, string $columnName)
Attributes for the element containing the content returned by getColumnContent().
augmentColumns(GridField $gridField, array $columns)
Modify the list of columns displayed in the table.
string
getColumnContent(GridField $gridField, ViewableData $record, string $columnName)
HTML for the column, content of the
array
getURLHandlers(GridField $gridField)
Return URLs to be handled by this grid field, in an array the same form as $url_handlers.
Handler methods will be called on the component, rather than the GridField.
array
getHTMLFragments(GridField $gridField)
Returns a map where the keys are fragment names and the values are pieces of HTML to add to these fragments.
Here are 4 built-in fragments: 'header', 'footer', 'before', and 'after', but components may also specify fragments of their own.
To specify a new fragment, specify a new fragment by including the text "$DefineFragment(fragmentname)" in the HTML that you return.
Fragment names should only contain alphanumerics, -, and _.
If you attempt to return HTML for a fragment that doesn't exist, an exception will be thrown when the GridField is rendered.
string
handleMoveToParent(GridField $gridField, $request)
Handle moving a record to a new parent
Form
handleNestedItem(GridField $gridField, HTTPRequest|null $request = null, ViewableData|null $record = null)
Handle the request to show a nested item
toggleNestedItem(GridField $gridField, HTTPRequest|null $request = null, ViewableData|null $record = null)
Handle the request to toggle a nested item in the gridfield state
string
Link($action = null)
Get the link for the nested grid field
string
ToggleLink($action = null)
Get the link for the toggle action
handleSave(GridField $gridField, DataObjectInterface $record)
Called when a grid field is saved - i.e. the form is submitted.