class GridFieldAddClassesButton implements GridField_HTMLProvider, GridField_ActionProvider (View source)

A button which allows objects to be created with a specified classname(s)

Properties

protected string $targetFragment

Name of fragment to insert into

protected string $buttonName

Button title

protected string $buttonClass

Additonal CSS classes for the button

protected array $modelClasses

Class names

Methods

public
__construct(array $classes, string $targetFragment = 'buttons-before-left')

No description

public
$this
setButtonName(string $name)

Change the button name

public
string
getButtonName()

Get the button name

public
string
getFragment()

Gets the fragment name this button is rendered into.

public
GridFieldAddNewInlineButton
setFragment(string $fragment)

Sets the fragment name this button is rendered into.

public
string
getButtonClass()

Get extra button class

public
$this
setButtonClass(string $buttonClass)

Sets extra CSS classes for this button

public
array
getClasses()

Get the classes of the objects to create

public
array
getClassesCreate(DataGrid $grid)

Gets the list of classes which can be created, with checks for permissions.

public
setClasses(array $classes)

Specify the classes to create

public
array
getHTMLFragments($grid)

Returns a map where the keys are fragment names and the values are pieces of HTML to add to these fragments.

public
array
getActions(GridField $gridField)

Return a list of the actions handled by this action provider.

protected
string
getAction()

Get the action suburl for this component

public
handleAction(GridField $gridField, string $actionName, array $arguments, array $data)

Handle an action on the given GridField.

public
null
handleAdd(GridField $grid)

Handles adding a new instance of a selected class.

Details

__construct(array $classes, string $targetFragment = 'buttons-before-left')

No description

Parameters

array $classes

Class or list of classes to create. If you enter more than one class, each click of the "add" button will create one of each

string $targetFragment

The fragment to render the button into

$this setButtonName(string $name)

Change the button name

Parameters

string $name

Return Value

$this

string getButtonName()

Get the button name

Return Value

string

string getFragment()

Gets the fragment name this button is rendered into.

Return Value

string

GridFieldAddNewInlineButton setFragment(string $fragment)

Sets the fragment name this button is rendered into.

Parameters

string $fragment

Return Value

GridFieldAddNewInlineButton $this

string getButtonClass()

Get extra button class

Return Value

string

$this setButtonClass(string $buttonClass)

Sets extra CSS classes for this button

Parameters

string $buttonClass

Return Value

$this

array getClasses()

Get the classes of the objects to create

Return Value

array

array getClassesCreate(DataGrid $grid)

Gets the list of classes which can be created, with checks for permissions.

Will fallback to the default model class for the given DataGrid

Parameters

DataGrid $grid

Return Value

array

setClasses(array $classes)

Specify the classes to create

Parameters

array $classes

array getHTMLFragments($grid)

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

$grid

Return Value

array

array getActions(GridField $gridField)

Return a list of the actions handled by this action provider.

Used to identify the action later on through the $actionName parameter in handleAction.

There is no namespacing on these actions, so you need to ensure that they don't conflict with other components.

Parameters

GridField $gridField

Return Value

array

with action identifier strings.

protected string getAction()

Get the action suburl for this component

Return Value

string

handleAction(GridField $gridField, string $actionName, array $arguments, array $data)

Handle an action on the given GridField.

Calls ALL components for every action handled, so the component needs to ensure it only accepts actions it is actually supposed to handle.

Parameters

GridField $gridField
string $actionName

Action identifier, see getActions().

array $arguments

Arguments relevant for this

array $data

All form data

null handleAdd(GridField $grid)

Handles adding a new instance of a selected class.

Parameters

GridField $grid

Return Value

null