class GridFieldAddByDBField implements GridField_ActionProvider, GridField_HTMLProvider (View source)

Adds a component which allows a user to add a new DataObject by database field.

Properties

protected string $targetFragment

HTML Fragment to render the field.

protected string $dataObjectField

Default field to create the DataObject by should be Title.

Methods

public
__construct(string $targetFragment = 'before', string $dataObjectField = 'Title')

Creates a text field and add button which allows the user to directly create a new DataObject by just entering the title.

public
array
getActions($gridField)

Provide actions to this component.

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

Handles the add action for the given DataObject.

public
string
getDataObjectField()

Returns the database field for which we'll add the new data object.

public
setDataObjectField($field)

Set the database field.

public
array
getHTMLFragments($gridField)

Renders the TextField and add button to the GridField.

Details

__construct(string $targetFragment = 'before', string $dataObjectField = 'Title')

Creates a text field and add button which allows the user to directly create a new DataObject by just entering the title.

Parameters

string $targetFragment
string $dataObjectField

array getActions($gridField)

Provide actions to this component.

Parameters

$gridField

Return Value

array

with action identifier strings.

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

Handles the add action for the given DataObject.

Parameters

GridField $gridField
$actionName
$arguments
$data

Exceptions

UnexpectedValueException

string getDataObjectField()

Returns the database field for which we'll add the new data object.

Return Value

string

setDataObjectField($field)

Set the database field.

Parameters

$field string

array getHTMLFragments($gridField)

Renders the TextField and add button to the GridField.

Parameters

$gridField

Return Value

array