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

public static 
create(mixed ...$args)

An implementation of the factory method, allows you to create an instance of a class

public static 
singleton(string $class = null)

Creates a class instance by the "singleton" design pattern.

public static 
config()

Get a configuration accessor for this class. Short hand for Config::inst()->get($this->class, .....).

public
mixed
uninherited(string $name)

Gets the uninherited value for the given config option

public
getStateManager()

Fallback on the direct Injector access, but allow a custom implementation to be applied

public
__construct($name = 'NestedForm')

No description

public
getGridField()

Get the grid field that this component is attached to

public
string
getRelationName()

Get the relation name to use for the nested grid fields

public
setRelationName(string $relationName)

Set the relation name to use for the nested grid fields

public
bool
getInlineEditable()

Get whether the nested grid fields should be inline editable

public
setInlineEditable(bool $editable)

Set whether the nested grid fields should be inline editable

public
setExpandNested(bool $expandNested)

Set whether the nested grid fields should be expanded by default

public
setForceClosedNested(bool $forceClosed)

Set whether the nested grid fields should be forced closed on load

public
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.

public
setMaxNestingLevel(int $level)

Set the maximum nesting level allowed for nested grid fields

public
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.

public
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.

public
array
getColumnsHandled(GridField $gridField)

Names of all columns which are affected by this component.

public
array
getColumnAttributes(GridField $gridField, ViewableData $record, string $columnName)

Attributes for the element containing the content returned by getColumnContent().

public
augmentColumns(GridField $gridField, array $columns)

Modify the list of columns displayed in the table.

public
string
getColumnContent(GridField $gridField, ViewableData $record, string $columnName)

HTML for the column, content of the element.

public
array
getURLHandlers(GridField $gridField)

Return URLs to be handled by this grid field, in an array the same form as $url_handlers.

public
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.

public
string
handleMoveToParent(GridField $gridField, $request)

Handle moving a record to a new parent

public
Form
handleNestedItem(GridField $gridField, HTTPRequest|null $request = null, ViewableData|null $record = null)

Handle the request to show a nested item

public
toggleNestedItem(GridField $gridField, HTTPRequest|null $request = null, ViewableData|null $record = null)

Handle the request to toggle a nested item in the gridfield state

public
string
Link($action = null)

Get the link for the nested grid field

public
string
ToggleLink($action = null)

Get the link for the toggle action

public
handleSave(GridField $gridField, DataObjectInterface $record)

Called when a grid field is saved - i.e. the form is submitted.

public
getManipulatedData(GridField $gridField, SS_List $dataList)

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();

Parameters

mixed ...$args

Return Value

Injectable

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).

Parameters

string $class

Optional classname to create, if the called class should not be used

Return Value

Injectable

The singleton instance

static Config_ForClass config()

Get a configuration accessor for this class. Short hand for Config::inst()->get($this->class, .....).

Return Value

Config_ForClass

mixed uninherited(string $name)

Gets the uninherited value for the given config option

Parameters

string $name

Return Value

mixed

GridFieldStateManagerInterface getStateManager()

Fallback on the direct Injector access, but allow a custom implementation to be applied

__construct($name = 'NestedForm')

No description

Parameters

$name

GridField getGridField()

Get the grid field that this component is attached to

Return Value

GridField

string getRelationName()

Get the relation name to use for the nested grid fields

Return Value

string

GridFieldNestedForm setRelationName(string $relationName)

Set the relation name to use for the nested grid fields

Parameters

string $relationName

Return Value

GridFieldNestedForm

bool getInlineEditable()

Get whether the nested grid fields should be inline editable

Return Value

bool

GridFieldNestedForm setInlineEditable(bool $editable)

Set whether the nested grid fields should be inline editable

Parameters

bool $editable

Return Value

GridFieldNestedForm

GridFieldNestedForm setExpandNested(bool $expandNested)

Set whether the nested grid fields should be expanded by default

Parameters

bool $expandNested

Return Value

GridFieldNestedForm

GridFieldNestedForm setForceClosedNested(bool $forceClosed)

Set whether the nested grid fields should be forced closed on load

Parameters

bool $forceClosed

Return Value

GridFieldNestedForm

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.

Parameters

callable|string $callback

Return Value

GridFieldNestedForm

GridFieldNestedForm setMaxNestingLevel(int $level)

Set the maximum nesting level allowed for nested grid fields

Parameters

int $level

Return Value

GridFieldNestedForm

int getMaxNestingLevel()

Get the max nesting level allowed for this grid field.

Return Value

int

protected bool atMaxNestingLevel(GridField $gridField)

Check if we are currently at the max nesting level allowed.

Parameters

GridField $gridField

Return Value

bool

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.

Parameters

GridField $gridField
string $columnName

Return Value

array
  • Map of arbitrary metadata identifiers to their values.

array getColumnsHandled(GridField $gridField)

Names of all columns which are affected by this component.

Parameters

GridField $gridField

Return Value

array

array getColumnAttributes(GridField $gridField, ViewableData $record, string $columnName)

Attributes for the element containing the content returned by getColumnContent().

Parameters

GridField $gridField
ViewableData $record

displayed in this row

string $columnName

Return Value

array

augmentColumns(GridField $gridField, array $columns)

Modify the list of columns displayed in the table.

Parameters

GridField $gridField
array $columns

List reference of all column names.

string getColumnContent(GridField $gridField, ViewableData $record, string $columnName)

HTML for the column, content of the element.

Parameters

GridField $gridField
ViewableData $record
  • Record displayed in this row
string $columnName

Return Value

string
  • HTML for the column. Return NULL to skip.

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.

Parameters

GridField $gridField

Return Value

array

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.

Parameters

GridField $gridField

Return Value

array

string handleMoveToParent(GridField $gridField, $request)

Handle moving a record to a new parent

Parameters

GridField $gridField
$request

Return Value

string

Form handleNestedItem(GridField $gridField, HTTPRequest|null $request = null, ViewableData|null $record = null)

Handle the request to show a nested item

Parameters

GridField $gridField
HTTPRequest|null $request
ViewableData|null $record

Return Value

Form

toggleNestedItem(GridField $gridField, HTTPRequest|null $request = null, ViewableData|null $record = null)

Handle the request to toggle a nested item in the gridfield state

Parameters

GridField $gridField
HTTPRequest|null $request
ViewableData|null $record

Get the link for the nested grid field

Parameters

$action

Return Value

string

Get the link for the toggle action

Parameters

$action

Return Value

string

handleSave(GridField $gridField, DataObjectInterface $record)

Called when a grid field is saved - i.e. the form is submitted.

Parameters

GridField $gridField
DataObjectInterface $record

SS_List getManipulatedData(GridField $gridField, SS_List $dataList)

Manipulate the SS_List as needed by this grid modifier.

Parameters

GridField $gridField
SS_List $dataList

Return Value

SS_List