SQLManyToOneColumn
extends SQLColumn
in package
Allows to define Many to One Columns.
Example: Book <> Author. Field "author_id" in table "books" is the Many to One Column.
Tags
Table of Contents
- VALID_OPTIONS = ['required', 'enum', 'max', 'min', 'tooltip', 'description', 'suffix', 'step', 'email', 'link', 'textarea', 'readonly', 'hidden', 'list', 'card', 'create', 'update', 'url', 'imageUrl']
- VALID_TYPES = ['text' => 'text', 'string' => 'text', 'integer' => 'integer', 'bigint' => 'integer', 'biginteger' => 'integer', 'smallint' => 'integer', 'int' => 'integer', 'decimal' => 'decimal', 'dec' => 'decimal', 'double' => 'decimal', 'float' => 'decimal', 'enum' => 'enum', 'datetime' => 'datetime', 'date' => 'date', 'time' => 'time', 'boolean' => 'boolean', 'bool' => 'boolean', 'tinyint' => 'boolean', 'blob' => 'blob', 'binary' => 'blob', 'bin' => 'blob', 'image' => 'image', 'picture' => 'image']
- $ajax : bool
- $columnName : string
- $filterDefinitions : array<string|int, FilterDefinition>
- $isCustomAjax : bool
- $isManyToOne : bool
- $label : string
- $manualInput : bool
- $name : string
- $onLoadCallback : callable
- $onSearchCallback : callable
- $options : array<string|int, mixed>
- $pageId : string
- $secondaryColumnNames : array<string|int, string>
- $toTableName : string
- $type : string
- $ajaxOptions : AjaxOptions
- __construct() : mixed
- Creates a new Many to One Column
- getAjaxOptions() : AjaxOptions
- getCardUrl() : string
- Gets the url to the card page of the related record.
- getColumnsForSelect() : array<string|int, string>
- getManyToOneValues() : array<string|int, mixed>
- Gets array of values.
- isHidden() : bool
- Checks if the column is hidden (in general or on a specific page type.)
- mapDatatype() : string
- Maps various names for datatypes to a uniform name.
- setAjaxOptions() : void
- triggerOnLoadEvent() : mixed
- triggerOnSearchEvent() : mixed
- checkOptions() : mixed
Constants
VALID_OPTIONS
public
mixed
VALID_OPTIONS
= ['required', 'enum', 'max', 'min', 'tooltip', 'description', 'suffix', 'step', 'email', 'link', 'textarea', 'readonly', 'hidden', 'list', 'card', 'create', 'update', 'url', 'imageUrl']
VALID_TYPES
public
array<string|int, string>
VALID_TYPES
= ['text' => 'text', 'string' => 'text', 'integer' => 'integer', 'bigint' => 'integer', 'biginteger' => 'integer', 'smallint' => 'integer', 'int' => 'integer', 'decimal' => 'decimal', 'dec' => 'decimal', 'double' => 'decimal', 'float' => 'decimal', 'enum' => 'enum', 'datetime' => 'datetime', 'date' => 'date', 'time' => 'time', 'boolean' => 'boolean', 'bool' => 'boolean', 'tinyint' => 'boolean', 'blob' => 'blob', 'binary' => 'blob', 'bin' => 'blob', 'image' => 'image', 'picture' => 'image']
Mapping datatye <> Datatype in database. Exampe dec = decimal, float = decimal
Properties
$ajax
public
bool
$ajax
= false
$columnName
public
string
$columnName
= ''
$filterDefinitions
public
array<string|int, FilterDefinition>
$filterDefinitions
= []
$isCustomAjax
public
bool
$isCustomAjax
= false
$isManyToOne
public
bool
$isManyToOne
= false
$label
public
string
$label
= null
$manualInput
public
bool
$manualInput
= false
$name
public
string
$name
= null
$onLoadCallback
public
callable
$onLoadCallback
= null
$onSearchCallback
public
callable
$onSearchCallback
= null
$options
public
array<string|int, mixed>
$options
= []
See class description above for options available
$pageId
public
string
$pageId
= ''
$secondaryColumnNames
public
array<string|int, string>
$secondaryColumnNames
= []
$toTableName
public
string
$toTableName
= ''
$type
public
string
$type
= null
$ajaxOptions
protected
AjaxOptions
$ajaxOptions
= null
Methods
__construct()
Creates a new Many to One Column
public
__construct(string $name, string $label, string $type, string $toTableName, string $columnName[, array<string|int, string> $secondaryColumnNames = [] ][, string $pageId = '' ][, array<string|int, FilterDefinition> $filterDefinitions = [] ][, array<string|int, mixed> $options = [] ][, bool $manualInput = false ][, bool $ajax = false ][, array<string|int, mixed> $ajaxOptions = null ]) : mixed
Parameters
- $name : string
- $label : string
- $type : string
-
See Class SQLColumn for types
- $toTableName : string
-
Curdkit table name
- $columnName : string
-
Primary relations column
- $secondaryColumnNames : array<string|int, string> = []
-
Secondary columns which will be shown to the user (more = slower)
- $pageId : string = ''
-
The drilldown page id
- $filterDefinitions : array<string|int, FilterDefinition> = []
-
(optional) Array of filter definitions to describe the relation.
- $options : array<string|int, mixed> = []
-
(optional) See Class SQLColumn for options
- $manualInput : bool = false
-
Allows the user to input custom data manually (without checking)
- $ajax : bool = false
-
Ajax powered value selection
- $ajaxOptions : array<string|int, mixed> = null
-
Options for the ajax
Tags
Return values
mixed —getAjaxOptions()
public
getAjaxOptions() : AjaxOptions
Return values
AjaxOptions —getCardUrl()
Gets the url to the card page of the related record.
public
getCardUrl(array<string|int, mixed> $record) : string
Parameters
- $record : array<string|int, mixed>
-
Record data
Return values
string —getColumnsForSelect()
public
getColumnsForSelect(bool $includeAjaxColumns) : array<string|int, string>
Parameters
- $includeAjaxColumns : bool
Return values
array<string|int, string> —getManyToOneValues()
Gets array of values.
public
getManyToOneValues([array<string|int, mixed> $record = [] ][, bool $onlyCurrentValue = false ]) : array<string|int, mixed>
Will be shown as
Parameters
- $record : array<string|int, mixed> = []
-
Record data
- $onlyCurrentValue : bool = false
Return values
array<string|int, mixed> —isHidden()
Checks if the column is hidden (in general or on a specific page type.)
public
isHidden([string $pageType = '' ]) : bool
Parameters
- $pageType : string = ''
-
Valid page types are: '','list','card','create','update' ('' = all pages)
Return values
bool —mapDatatype()
Maps various names for datatypes to a uniform name.
public
static mapDatatype(string $datatype[, string $columnName = '' ]) : string
Example: string, text = text
Example: int, integer, bigint = integer
Parameters
- $datatype : string
-
The name of the datatype
- $columnName : string = ''
-
The name of the column for a more precise exception message, if needed.
Tags
Return values
string —the uniform datatype name
setAjaxOptions()
public
setAjaxOptions([AjaxOptions $ajaxOptions = null ]) : void
Parameters
- $ajaxOptions : AjaxOptions = null
Return values
void —triggerOnLoadEvent()
public
triggerOnLoadEvent(mixed &$value, mixed $record, TableDescriptor $table, PageDescriptor $page, SQLColumn $column) : mixed
Parameters
- $value : mixed
- $record : mixed
- $table : TableDescriptor
- $page : PageDescriptor
- $column : SQLColumn
Return values
mixed —triggerOnSearchEvent()
public
triggerOnSearchEvent(mixed &$results, mixed $input, TableDescriptor $table, PageDescriptor $page, SQLColumn $column) : mixed
Parameters
- $results : mixed
- $input : mixed
- $table : TableDescriptor
- $page : PageDescriptor
- $column : SQLColumn
Return values
mixed —checkOptions()
private
checkOptions() : mixed