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'
$defaultValue
public
mixed
$defaultValue
$deprecated
public
bool
$deprecated
= FALSE
$description
Explanation of the purpose of the field.
public
string
$description
$dfkEntities
public
string
$dfkEntities
$entity
public
string
$entity
$fkColumn
public
array<string|int, mixed>
$fkColumn
$fkEntity
public
string
$fkEntity
$helpPost
public
string
$helpPost
$helpPre
public
string
$helpPre
$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'
$nullable
public
bool
$nullable
= TRUE
$operators
If set, limits the operators that can be used on this field for "get" actions.
public
array<string|int, string>
$operators
$options
public
array<string|int, mixed>|bool
$options
$optionsCallback
public
callable
$optionsCallback
$optionsCallbackParams
public
array<string|int, mixed>
$optionsCallbackParams
= []
$outputFormatters
public
array<string|int, callable>
$outputFormatters
$permission
public
array<string|int, mixed>
$permission
$readonly
public
bool
$readonly
= FALSE
$required
public
bool
$required
= FALSE
$requiredIf
public
string
$requiredIf
$serialize
public
int
$serialize
Tags
$sqlFilters
Some fields use a callback to generate their SQL (for reading/searching).
public
array<string|int, callable>
$sqlFilters
$sqlRenderer
public
callable
$sqlRenderer
$suffixes
public
array<string|int, mixed>|null
$suffixes
$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
$thisaddSqlFilter()
public
addSqlFilter(callable $sqlFilter) : $this
Parameters
- $sqlFilter : callable
Return values
$thisgetColumnName()
public
getColumnName() : string|null
Return values
string|nullgetDataType()
public
getDataType() : string
Return values
stringgetDefaultValue()
public
getDefaultValue() : mixed
getDescription()
public
getDescription() : string
Return values
stringgetDfkEntities()
public
getDfkEntities() : array<string|int, mixed>|null
Return values
array<string|int, mixed>|nullgetEntity()
public
getEntity() : string
Return values
stringgetFkColumn()
public
getFkColumn() : string|null
Return values
string|nullgetFkEntity()
public
getFkEntity() : string
Return values
stringgetInputAttrs()
public
getInputAttrs() : array<string|int, mixed>
Return values
array<string|int, mixed>getInputType()
public
getInputType() : string
Return values
stringgetLabel()
public
getLabel() : string
Return values
stringgetLocalizable()
public
getLocalizable() : bool
Return values
boolgetName()
public
getName() : string
Return values
stringgetNullable()
public
getNullable() : bool
Return values
boolgetPermission()
public
getPermission() : array<string|int, mixed>
Return values
array<string|int, mixed>getReadonly()
public
getReadonly() : bool
Return values
boolgetRequiredIf()
public
getRequiredIf() : string
Return values
stringgetSerialize()
public
getSerialize() : int
Return values
intgetTableName()
public
getTableName() : string
Return values
stringgetTitle()
public
getTitle() : string
Return values
stringgetUsage()
public
getUsage() : array<string|int, string>
Return values
array<string|int, string>isRequired()
public
isRequired() : bool
Return values
boolloadArray()
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
$thissetColumnName()
public
setColumnName(string|null $columnName) : $this
Parameters
- $columnName : string|null
Return values
$thissetDataType()
public
setDataType(mixed $dataType) : $this
Parameters
- $dataType : mixed
Tags
Return values
$thissetDefaultValue()
public
setDefaultValue(mixed $defaultValue) : $this
Parameters
- $defaultValue : mixed
Return values
$thissetDeprecated()
public
setDeprecated(bool $deprecated) : $this
Parameters
- $deprecated : bool
Return values
$thissetDescription()
public
setDescription(string $description) : $this
Parameters
- $description : string
Return values
$thissetDfkEntities()
public
setDfkEntities(array<string|int, mixed>|null $dfkEntities) : $this
Parameters
- $dfkEntities : array<string|int, mixed>|null
Return values
$thissetEntity()
public
setEntity(string $entity) : $this
Parameters
- $entity : string
Return values
$thissetFkColumn()
public
setFkColumn(string $fkColumn) : $this
Parameters
- $fkColumn : string
Return values
$thissetFkEntity()
public
setFkEntity(string $fkEntity) : $this
Parameters
- $fkEntity : string
Return values
$thissetHelpPost()
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
$thissetInputAttrs()
public
setInputAttrs(array<string|int, mixed> $inputAttrs) : $this
Parameters
- $inputAttrs : array<string|int, mixed>
Return values
$thissetInputType()
public
setInputType(string $inputType) : $this
Parameters
- $inputType : string
Return values
$thissetLabel()
public
setLabel(string $label) : $this
Parameters
- $label : string
Return values
$thissetLocalizable()
public
setLocalizable(bool $localizable) : $this
Parameters
- $localizable : bool
Return values
$thissetName()
public
setName(string $name) : $this
Parameters
- $name : string
Return values
$thissetNullable()
public
setNullable(bool $nullable) : $this
Parameters
- $nullable : bool
Return values
$thissetOperators()
public
setOperators(array<string|int, string> $operators) : $this
Parameters
- $operators : array<string|int, string>
Return values
$thissetOptions()
public
setOptions(array<string|int, mixed>|bool $options) : $this
Parameters
- $options : array<string|int, mixed>|bool
Return values
$thissetOptionsCallback()
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
$thissetOutputFormatters()
public
setOutputFormatters(array<string|int, callable> $outputFormatters) : $this
Parameters
- $outputFormatters : array<string|int, callable>
Return values
$thissetPermission()
public
setPermission(array<string|int, mixed> $permission) : $this
Parameters
- $permission : array<string|int, mixed>
Return values
$thissetReadonly()
public
setReadonly(bool $readonly) : $this
Parameters
- $readonly : bool
Return values
$thissetRequired()
public
setRequired(bool $required) : $this
Parameters
- $required : bool
Return values
$thissetRequiredIf()
public
setRequiredIf(string|null $requiredIf) : $this
Parameters
- $requiredIf : string|null
Return values
$thissetSerialize()
public
setSerialize(int|string|null $serialize) : $this
Parameters
- $serialize : int|string|null
Return values
$thissetSqlFilters()
public
setSqlFilters(array<string|int, callable> $sqlFilters) : $this
Parameters
- $sqlFilters : array<string|int, callable>
Return values
$thissetSqlRenderer()
public
setSqlRenderer(callable $sqlRenderer) : $this
Parameters
- $sqlRenderer : callable
Return values
$thissetSuffixes()
public
setSuffixes(array<string|int, mixed> $suffixes) : $this
Parameters
- $suffixes : array<string|int, mixed>
Return values
$thissetTableName()
public
setTableName(string $tableName) : $this
Parameters
- $tableName : string
Return values
$thissetTitle()
public
setTitle(string $title) : $this
Parameters
- $title : string
Return values
$thissetType()
public
setType(string $type) : $this
Parameters
- $type : string
Return values
$thissetUsage()
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>