Documentation

FieldSpec
in package
uses BasicSpecTrait, DataTypeSpecTrait, OptionsSpecTrait, GuiSpecTrait, SqlSpecTrait, ArrayFormatTrait

Contains APIv4 field metadata

Table of Contents

Properties

$columnName  : string
SQL column which stores this field.
$dataType  : string
The type of data stored in this field.
$defaultValue  : mixed
$deprecated  : bool
$description  : string
Explanation of the purpose of the field.
$dfkEntities  : string
$entity  : string
$fkColumn  : array<string|int, mixed>
$fkEntity  : string
$helpPost  : string
$helpPre  : string
$inputAttrs  : array<string|int, mixed>
$inputType  : string
Default widget to use when presenting this field.
$label  : string
User-facing label, shown on most forms and displays
$localizable  : bool
Can the field be translated.
$name  : string
Symbolic name of the field.
$nullable  : bool
$operators  : array<string|int, string>
If set, limits the operators that can be used on this field for "get" actions.
$options  : array<string|int, mixed>|bool
$optionsCallback  : callable
$optionsCallbackParams  : array<string|int, mixed>
$outputFormatters  : array<string|int, callable>
$permission  : array<string|int, mixed>
$readonly  : bool
$required  : bool
$requiredIf  : string
$serialize  : int
$sqlFilters  : array<string|int, callable>
Some fields use a callback to generate their SQL (for reading/searching).
$sqlRenderer  : callable
$suffixes  : array<string|int, mixed>|null
$tableName  : string
SQL table which stores this field.
$title  : string
Backend-facing label. Shown in API, exports, and other configuration systems.
$type  : string
Meta-type indicating how this field was defined/implemented.
$typeAliases  : array<string|int, mixed>
Aliases for the valid data types
$usage  : array<string|int, string>

Methods

__construct()  : mixed
addOutputFormatter()  : $this
addSqlFilter()  : $this
getColumnName()  : string|null
getDataType()  : string
getDefaultValue()  : mixed
getDescription()  : string
getDfkEntities()  : array<string|int, mixed>|null
getEntity()  : string
getFkColumn()  : string|null
getFkEntity()  : string
getInputAttrs()  : array<string|int, mixed>
getInputType()  : string
getLabel()  : string
getLocalizable()  : bool
getName()  : string
getNullable()  : bool
getPermission()  : array<string|int, mixed>
getReadonly()  : bool
getRequiredIf()  : string
getSerialize()  : int
getTableName()  : string
getTitle()  : string
getUsage()  : array<string|int, string>
isRequired()  : bool
loadArray()  : $this
Populate this field-spec using values from an array.
setColumnName()  : $this
setDataType()  : $this
setDefaultValue()  : $this
setDeprecated()  : $this
setDescription()  : $this
setDfkEntities()  : $this
setEntity()  : $this
setFkColumn()  : $this
setFkEntity()  : $this
setHelpPost()  : mixed
setHelpPre()  : mixed
setInputAttr()  : $this
setInputAttrs()  : $this
setInputType()  : $this
setLabel()  : $this
setLocalizable()  : $this
setName()  : $this
setNullable()  : $this
setOperators()  : $this
setOptions()  : $this
setOptionsCallback()  : $this
setOutputFormatters()  : $this
setPermission()  : $this
setReadonly()  : $this
setRequired()  : $this
setRequiredIf()  : $this
setSerialize()  : $this
setSqlFilters()  : $this
setSqlRenderer()  : $this
setSuffixes()  : $this
setTableName()  : $this
setTitle()  : $this
setType()  : $this
setUsage()  : void
toArray()  : array<string|int, mixed>
Gets all public variables, converted to snake_case
getValidDataTypes()  : array<string|int, mixed>
Add valid types that are not not part of \CRM_Utils_Type::dataTypes

Properties

$columnName

SQL column which stores this field.

public string $columnName

$dataType

The type of data stored in this field.

public string $dataType

Ex: 'Integer', 'Boolean', 'Float', 'String', 'Text', 'Blob'

$description

Explanation of the purpose of the field.

public string $description

$inputAttrs

public array<string|int, mixed> $inputAttrs = []

$inputType

Default widget to use when presenting this field.

public string $inputType

Ex: 'RichTextEditor'

$label

User-facing label, shown on most forms and displays

public string $label

Default label to use when presenting this field to an end-user (e.g. on a data-entry form or a data-column view).

$localizable

Can the field be translated.

public bool $localizable = FALSE

$name

Symbolic name of the field.

public string $name

Ex: 'first_name'

$operators

If set, limits the operators that can be used on this field for "get" actions.

public array<string|int, string> $operators

$optionsCallbackParams

public array<string|int, mixed> $optionsCallbackParams = []

$outputFormatters

public array<string|int, callable> $outputFormatters

$permission

public array<string|int, mixed> $permission

$serialize

public int $serialize
Tags
see

CRM_Core_DAO::SERIALIZE_SEPARATOR_BOOKEND, CRM_Core_DAO::SERIALIZE_JSON, etc

$sqlFilters

Some fields use a callback to generate their SQL (for reading/searching).

public array<string|int, callable> $sqlFilters

$tableName

SQL table which stores this field.

public string $tableName

$title

Backend-facing label. Shown in API, exports, and other configuration systems.

public string $title

If this field is presented to an administrator (e.g. when configuring a screen or configuring process-automation), how the field be entitled?

Ex: ts('First Name')

$type

Meta-type indicating how this field was defined/implemented.

public string $type = 'Extra'

Ex: 'Field' (normal/standard DB field), 'Custom' (auxiliary DB field), 'Filter' (read-oriented filter option), 'Extra' (special/programmatic field).

$typeAliases

Aliases for the valid data types

public static array<string|int, mixed> $typeAliases = ['Int' => 'Integer', 'Link' => 'Url', 'Memo' => 'Text']

$usage

public array<string|int, string> $usage = []

Methods

__construct()

public __construct(string $name, string $entity[, string $dataType = 'String' ]) : mixed
Parameters
$name : string
$entity : string
$dataType : string = 'String'

addOutputFormatter()

public addOutputFormatter(callable $outputFormatter) : $this
Parameters
$outputFormatter : callable
Return values
$this

addSqlFilter()

public addSqlFilter(callable $sqlFilter) : $this
Parameters
$sqlFilter : callable
Return values
$this

getColumnName()

public getColumnName() : string|null
Return values
string|null

getDefaultValue()

public getDefaultValue() : mixed

getDescription()

public getDescription() : string
Return values
string

getDfkEntities()

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

getEntity()

public getEntity() : string
Return values
string

getInputAttrs()

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

getInputType()

public getInputType() : string
Return values
string

getLabel()

public getLabel() : string
Return values
string

getLocalizable()

public getLocalizable() : bool
Return values
bool

getNullable()

public getNullable() : bool
Return values
bool

getPermission()

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

getReadonly()

public getReadonly() : bool
Return values
bool

getRequiredIf()

public getRequiredIf() : string
Return values
string

getTableName()

public getTableName() : string
Return values
string

getUsage()

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

isRequired()

public isRequired() : bool
Return values
bool

loadArray()

Populate this field-spec using values from an array.

public loadArray(iterable<string|int, mixed> $values[, bool $strict = FALSE ]) : $this
Parameters
$values : iterable<string|int, mixed>

List of public variables, expressed in snake_case. Ex: ['title' => 'Color', 'default_value' => '#f00']

$strict : bool = FALSE

In strict mode, properties are only accepted if they are formally defined on the current class.

Return values
$this

setColumnName()

public setColumnName(string|null $columnName) : $this
Parameters
$columnName : string|null
Return values
$this

setDefaultValue()

public setDefaultValue(mixed $defaultValue) : $this
Parameters
$defaultValue : mixed
Return values
$this

setDeprecated()

public setDeprecated(bool $deprecated) : $this
Parameters
$deprecated : bool
Return values
$this

setDescription()

public setDescription(string $description) : $this
Parameters
$description : string
Return values
$this

setDfkEntities()

public setDfkEntities(array<string|int, mixed>|null $dfkEntities) : $this
Parameters
$dfkEntities : array<string|int, mixed>|null
Return values
$this

setEntity()

public setEntity(string $entity) : $this
Parameters
$entity : string
Return values
$this

setFkColumn()

public setFkColumn(string $fkColumn) : $this
Parameters
$fkColumn : string
Return values
$this

setFkEntity()

public setFkEntity(string $fkEntity) : $this
Parameters
$fkEntity : string
Return values
$this

setHelpPost()

public setHelpPost(string|null $helpPost) : mixed
Parameters
$helpPost : string|null

setHelpPre()

public setHelpPre(string|null $helpPre) : mixed
Parameters
$helpPre : string|null

setInputAttr()

public setInputAttr(string $attrName, mixed $attrValue) : $this
Parameters
$attrName : string
$attrValue : mixed
Return values
$this

setInputAttrs()

public setInputAttrs(array<string|int, mixed> $inputAttrs) : $this
Parameters
$inputAttrs : array<string|int, mixed>
Return values
$this

setInputType()

public setInputType(string $inputType) : $this
Parameters
$inputType : string
Return values
$this

setLabel()

public setLabel(string $label) : $this
Parameters
$label : string
Return values
$this

setLocalizable()

public setLocalizable(bool $localizable) : $this
Parameters
$localizable : bool
Return values
$this

setName()

public setName(string $name) : $this
Parameters
$name : string
Return values
$this

setNullable()

public setNullable(bool $nullable) : $this
Parameters
$nullable : bool
Return values
$this

setOperators()

public setOperators(array<string|int, string> $operators) : $this
Parameters
$operators : array<string|int, string>
Return values
$this

setOptions()

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

setOptionsCallback()

public setOptionsCallback(callable $callback[, array<string|int, mixed> $params = [] ]) : $this
Parameters
$callback : callable

Function to be called, will receive the following arguments: ($this, $values, $returnFormat, $checkPermissions, $params)

$params : array<string|int, mixed> = []

Array of optional extra data; sent as 5th argument to the callback

Return values
$this

setOutputFormatters()

public setOutputFormatters(array<string|int, callable> $outputFormatters) : $this
Parameters
$outputFormatters : array<string|int, callable>
Return values
$this

setPermission()

public setPermission(array<string|int, mixed> $permission) : $this
Parameters
$permission : array<string|int, mixed>
Return values
$this

setReadonly()

public setReadonly(bool $readonly) : $this
Parameters
$readonly : bool
Return values
$this

setRequired()

public setRequired(bool $required) : $this
Parameters
$required : bool
Return values
$this

setRequiredIf()

public setRequiredIf(string|null $requiredIf) : $this
Parameters
$requiredIf : string|null
Return values
$this

setSerialize()

public setSerialize(int|string|null $serialize) : $this
Parameters
$serialize : int|string|null
Return values
$this

setSqlFilters()

public setSqlFilters(array<string|int, callable> $sqlFilters) : $this
Parameters
$sqlFilters : array<string|int, callable>
Return values
$this

setSqlRenderer()

public setSqlRenderer(callable $sqlRenderer) : $this
Parameters
$sqlRenderer : callable
Return values
$this

setSuffixes()

public setSuffixes(array<string|int, mixed> $suffixes) : $this
Parameters
$suffixes : array<string|int, mixed>
Return values
$this

setTableName()

public setTableName(string $tableName) : $this
Parameters
$tableName : string
Return values
$this

setTitle()

public setTitle(string $title) : $this
Parameters
$title : string
Return values
$this

setType()

public setType(string $type) : $this
Parameters
$type : string
Return values
$this

setUsage()

public setUsage(array<string|int, string> $usage) : void
Parameters
$usage : array<string|int, string>

toArray()

Gets all public variables, converted to snake_case

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

getValidDataTypes()

Add valid types that are not not part of \CRM_Utils_Type::dataTypes

protected getValidDataTypes() : array<string|int, mixed>
Return values
array<string|int, mixed>

        
On this page

Search results