CRUDKit api-doc [Developer]

Lookup
in package

A lookup is a calculated field with values from other tables or fixed values

Table of Contents

BTNCLASSES  = ['default', 'primary', 'info', 'success', 'danger', 'warning', 'accent']
POSITIONS  = ['before-field', 'after-field', 'to-field']
VALUETYPES  = ['lookup', 'lookup-all', 'const', 'count', 'sum']
$btnClass  : mixed
$cardPage  : mixed
$drillDownLink  : mixed
$drillDownTarget  : mixed
$enabled  : mixed
$faIcon  : mixed
$fieldname  : mixed
$filterDefinitions  : array<string|int, FilterDefinition>
$label  : mixed
$lookupAllSeparator  : mixed
$onCard  : mixed
$onList  : mixed
$onUpdate  : mixed
$pageId  : mixed
$position  : mixed
$tableFieldname  : mixed
$value  : mixed
$valueType  : mixed
$visible  : mixed
$overrideDrillDownLink  : mixed
$table  : TableDescriptor
__construct()  : Lookup
Creates a Lookup
addFilterDefinitiona()  : Lookup
Add a filter definitinon for the reference table
calculateLookup()  : void
Calculates the values of the lookup field
getDrillDownLink()  : string
Gets the link for the related page (card or list)
setBtnClass()  : mixed
Defines the button appearance.
setCardPage()  : Lookup
Set if the drilldown Page is a cardpage
setDrillDownLink()  : Lookup
Set the drilldown link maunally
setDrillDownTarget()  : Lookup
Set the target for the drilldown link (_blank, _self, _parent, _top). Default is _self
setEnabled()  : Lookup
Enableds/disables the action
setFaIcon()  : Lookup
Sets the icon for the button (font awesome icon name)
setFieldname()  : Lookup
Set reference fieldname for $position
setLabel()  : Lookup
Set the label of the action/lookup on pages
setLookupAllSeparator()  : Lookup
Set the separator string for $valueType
setOnCard()  : Lookup
Show/hide on card pages.
setOnList()  : Lookup
Show/hide on list pages.
setOnUpdate()  : Lookup
Show/hides on update pages.
setPageId()  : Lookup
Set the drilldown pageId
setPosition()  : Lookup
Set the position of the lookup 'before-field', 'after-field', 'to-field'
setTable()  : Lookup
Set the reference table
setTableFieldname()  : Lookup
Set the fieldname of the reference table (for lookup)
setValue()  : Lookup
Set the value of the action/lookup on pages
setValueType()  : Lookup
Set the value type lookup', 'lookup-all', 'const', 'count', 'sum'
setVisible()  : Lookup
Show/hide.

Constants

BTNCLASSES

public mixed BTNCLASSES = ['default', 'primary', 'info', 'success', 'danger', 'warning', 'accent']

POSITIONS

public mixed POSITIONS = ['before-field', 'after-field', 'to-field']
Tags
internal

VALUETYPES

public mixed VALUETYPES = ['lookup', 'lookup-all', 'const', 'count', 'sum']

Properties

$btnClass

public mixed $btnClass = 'default'

$cardPage

public mixed $cardPage = false
public mixed $drillDownLink = ''

$drillDownTarget

public mixed $drillDownTarget = '_self'

$enabled

public mixed $enabled = true

$faIcon

public mixed $faIcon = ''

$fieldname

public mixed $fieldname = ''

$filterDefinitions

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

fitlers for the reference talbe

$lookupAllSeparator

public mixed $lookupAllSeparator = ', '

$onCard

public mixed $onCard = true

$onList

public mixed $onList = true

$onUpdate

public mixed $onUpdate = true

$pageId

public mixed $pageId = ''

$position

public mixed $position = ''

$tableFieldname

public mixed $tableFieldname = ''

$valueType

public mixed $valueType = 'lookup'

$visible

public mixed $visible = true
private mixed $overrideDrillDownLink = false

Methods

__construct()

Creates a Lookup

public __construct(TableDescriptor $table, string $tableFieldname, array<string|int, mixed> $filterDefinitions, string $valueType, string $label, string $position, string $fieldname[, string $pageId = '' ][, bool $cardPage = false ][, string $value = '' ]) : Lookup
Parameters
$table : TableDescriptor

the reference table for the lookup

$tableFieldname : string

the fieldname in the recerence table

$filterDefinitions : array<string|int, mixed>

fitlers for the reference talbe

$valueType : string

Defines which value(s) the lookup should fetch from the related table´s column:

  • 'lookup': fetches the value of $tableFieldname from a single record: typically used when the filters result in a single record
  • 'lookup-all': fetches the values of $tableFieldname from multiple records and glues them together with $lookupAllSeparator: typically used when the filters result in multiple records
  • 'const': fetches a constant value defined by $value: makes sense if you dont want to show data from another table, but to crate some sort of link to it
  • 'count': fetches records from the other table and counts them
  • 'sum': fetches the values of $tableFieldname from multiple records sums them up: typically used when creating totals. Requires $tableFieldname to be a numeric field.
$label : string

The text of the label for this Lookup

$position : string

Position on card page. 'before-field', 'after-field', 'to-field'

$fieldname : string

The reference field for $position

$pageId : string = ''
$cardPage : bool = false

Shows the related record in a card page (fitlers have to return exactly one record!)

$value : string = ''

The value for $valueType 'const'

Tags
stackable
Return values
Lookup

calculateLookup()

Calculates the values of the lookup field

public calculateLookup(array<string|int, mixed> $record[, bool $calculateLink = true ]) : void
Parameters
$record : array<string|int, mixed>

The source record

$calculateLink : bool = true
Return values
void

Gets the link for the related page (card or list)

public getDrillDownLink(array<string|int, mixed> $record) : string
Parameters
$record : array<string|int, mixed>

The reference record

Return values
string

setBtnClass()

Defines the button appearance.

public setBtnClass([string $btnClass = 'default' ]) : mixed

Admin LTE button type. ''|'default'|'primary'|'info'|'success'|'danger'|'warning'|'accent'

Parameters
$btnClass : string = 'default'
Tags
stackable
Return values
mixed

setCardPage()

Set if the drilldown Page is a cardpage

public setCardPage(bool $cardPage) : Lookup
Parameters
$cardPage : bool
Return values
Lookup

Set the drilldown link maunally

public setDrillDownLink(string $drillDownLink[, bool $override = true ]) : Lookup
Parameters
$drillDownLink : string
$override : bool = true

If this is set to true, the lookup will always take the link you provide instead of calculating one base on the table and filters

Return values
Lookup

setDrillDownTarget()

Set the target for the drilldown link (_blank, _self, _parent, _top). Default is _self

public setDrillDownTarget(string $drillDownTarget) : Lookup
Parameters
$drillDownTarget : string
Return values
Lookup

setEnabled()

Enableds/disables the action

public setEnabled([bool $enabled = true ]) : Lookup
Parameters
$enabled : bool = true
Tags
stackable
Return values
Lookup

setFaIcon()

Sets the icon for the button (font awesome icon name)

public setFaIcon(string $faIcon) : Lookup
Parameters
$faIcon : string
Return values
Lookup

setFieldname()

Set reference fieldname for $position

public setFieldname(string $fieldname) : Lookup
Parameters
$fieldname : string
Return values
Lookup

setLabel()

Set the label of the action/lookup on pages

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

setLookupAllSeparator()

Set the separator string for $valueType

public setLookupAllSeparator(string $lookupAllSeparator) : Lookup
Parameters
$lookupAllSeparator : string
Return values
Lookup

setOnCard()

Show/hide on card pages.

public setOnCard([bool $onCard = true ]) : Lookup
Parameters
$onCard : bool = true
Return values
Lookup

setOnList()

Show/hide on list pages.

public setOnList([bool $onList = true ]) : Lookup
Parameters
$onList : bool = true
Return values
Lookup

setOnUpdate()

Show/hides on update pages.

public setOnUpdate([bool $onUpdate = true ]) : Lookup
Parameters
$onUpdate : bool = true
Return values
Lookup

setPageId()

Set the drilldown pageId

public setPageId(string $pageId) : Lookup
Parameters
$pageId : string
Return values
Lookup

setPosition()

Set the position of the lookup 'before-field', 'after-field', 'to-field'

public setPosition(string $position) : Lookup
Parameters
$position : string
Return values
Lookup

setTableFieldname()

Set the fieldname of the reference table (for lookup)

public setTableFieldname(string $tableFieldname) : Lookup
Parameters
$tableFieldname : string
Return values
Lookup

setValue()

Set the value of the action/lookup on pages

public setValue(string $value) : Lookup
Parameters
$value : string
Return values
Lookup

setValueType()

Set the value type lookup', 'lookup-all', 'const', 'count', 'sum'

public setValueType(string $valueType) : Lookup
Parameters
$valueType : string
Return values
Lookup

setVisible()

Show/hide.

public setVisible([bool $visible = true ]) : Lookup
Parameters
$visible : bool = true
Tags
stackable
Return values
Lookup

Search results