Craft Themes (4.x)

CraftFieldInterface extends FieldInterface

Class that handles most Craft fields (all of them apart from Matrix and Table)

Table of Contents

buildConfig()  : array<string|int, mixed>
Build config from a field
create()  : FieldInterface
Create a new field from config
delete()  : bool
Delete a field
forField()  : string
For which craft field class this field should be used
getAvailableDisplayers()  : array<string|int, FieldDisplayerInterface>
Get all the displayers that can display this field
getCanBeCached()  : bool
Can this field be cached
getChildFieldName()  : string
Get the name of a field child of this field. This would only be used for fields that have children (Neo, Matrix etc)
getChildren()  : array<string|int, mixed>
Get this field's children
getCraftField()  : Field
Get the associated craft field instance
getDisplayer()  : FieldDisplayerInterface
Get the displayer for this field
getDisplayerHandle()  : string
Displayer handle getter
getDisplayName()  : string
Name to display
getFieldTemplates()  : array<string|int, string>
Get available field templates
getFileTemplates()  : array<string|int, string>
Get available file templates
getOptions()  : array<string|int, mixed>
Options getter
getParent()  : FieldInterface|null
Parent getter
getTargetClass()  : string
The class used by displayer for their field targets Will be the field class for custom fields and the craft field class for craft fields
handleChanged()  : bool
Handle a project config change
handleDeleted()  : mixed
Deletes a field record
populateFromData()  : mixed
Populate this field from array of data
rebuild()  : mixed
Rebuild the field
render()  : Markup
Render this item.
save()  : bool
Saves a field
setDisplayerHandle()  : mixed
Displayer handle setter
setOptions()  : mixed
Options setter
setParent()  : mixed
Parent setter
shouldExistOnLayout()  : bool
Should this field exist on a layout, called during the creation of a layout to automatically create this field on that layout.

Methods

buildConfig()

Build config from a field

public static buildConfig(Field $craftField) : array<string|int, mixed>
Parameters
$craftField : Field
Return values
array<string|int, mixed>

forField()

For which craft field class this field should be used

public static forField() : string
Return values
string

getCanBeCached()

Can this field be cached

public getCanBeCached() : bool
Return values
bool

getChildFieldName()

Get the name of a field child of this field. This would only be used for fields that have children (Neo, Matrix etc)

public getChildFieldName(FieldInterface $field) : string
Parameters
$field : FieldInterface
Tags
since
4.1.0
Return values
string

getChildren()

Get this field's children

public getChildren() : array<string|int, mixed>
Tags
since
3.1.0
Return values
array<string|int, mixed>

getCraftField()

Get the associated craft field instance

public getCraftField() : Field
Return values
Field

getDisplayerHandle()

Displayer handle getter

public getDisplayerHandle() : string
Return values
string

getDisplayName()

Name to display

public getDisplayName() : string
Return values
string

getFieldTemplates()

Get available field templates

public getFieldTemplates() : array<string|int, string>
Return values
array<string|int, string>

getOptions()

Options getter

public getOptions() : array<string|int, mixed>
Return values
array<string|int, mixed>

getTargetClass()

The class used by displayer for their field targets Will be the field class for custom fields and the craft field class for craft fields

public getTargetClass() : string
Return values
string

handleChanged()

Handle a project config change

public static handleChanged(string $uid, array<string|int, mixed> $data) : bool
Parameters
$uid : string
$data : array<string|int, mixed>
Return values
bool

handleDeleted()

Deletes a field record

public static handleDeleted(array<string|int, mixed> $uid, array<string|int, mixed> $data) : mixed
Parameters
$uid : array<string|int, mixed>
$data : array<string|int, mixed>
Return values
mixed

populateFromData()

Populate this field from array of data

public populateFromData(array<string|int, mixed> $data) : mixed
Parameters
$data : array<string|int, mixed>
Return values
mixed

rebuild()

Rebuild the field

public rebuild() : mixed
Return values
mixed

render()

Render this item.

public render([mixed $value = null ]) : Markup

Custom field must override this to pull the correct value from the element being rendered which can be pulled from the View service.

Parameters
$value : mixed = null
Return values
Markup

setDisplayerHandle()

Displayer handle setter

public setDisplayerHandle(string $handle) : mixed
Parameters
$handle : string
Return values
mixed

setOptions()

Options setter

public setOptions(array<string|int, mixed>|null $options) : mixed
Parameters
$options : array<string|int, mixed>|null
Return values
mixed

shouldExistOnLayout()

Should this field exist on a layout, called during the creation of a layout to automatically create this field on that layout.

public static shouldExistOnLayout(LayoutInterface $layout) : bool
Parameters
$layout : LayoutInterface
Return values
bool

Search results