TableMultiForm
extends MultiForm
in package
Displays multi-form as table
Table of Contents
Properties
- $blockPara : array{0: string, 1?: string|null, 2?: bool}|null
- $class : string|null
- $dependents : array<int, array<string, mixed>>
- $duplicates : array<int, array<string, mixed>>
- $errors : array<string|int, string>
- $exists : bool
- $fixed : bool
- $foreign : array<string, array<string, mixed>>
- $formChildren : array<string|int, Form>
- $forms : array<string|int, Form>
- $id : string|int
- $idParent : int|null
- $inputs : array<string, Input>
- $labelPara : string
- $legend : string|null
- $oldKey : mixed
- $parent : string|null
- $presets : array<string, mixed>|null
- $primary : string
- $purge : bool
- $required : bool|null
- $tableColumns : int
- $type : int
- $uniqueKey : bool
- $uniques : array<string, array<string, mixed>>
- $changeable : bool
- $childClass : string
- $columnOrder : array<string, bool>
- $data : array<string|int, mixed>
- $db : SQL
- $dummyForms : array<string|int, Form>
- $editable : bool
- $formParent : Form|null
- $jForm : string
- $max : int
- $min : int
- $multiple : bool
- $order : array<string, string>
- $plugins : array<string|int, Plugin>
- $scripts : array<string, mixed>
- $table : string|null
- $template : array<string, string>|null
- $where : array<string, mixed>|string|null
Methods
- __construct() : mixed
- __toString() : mixed
- addComment() : void
- Insert comment
- addDependent() : void
- Tables that depend on the primary key of this table
- addDuplicate() : void
- Content of inputs that can be duplicated if the target input is empty
- addForeign() : void
- Foreign key - values
- addForm() : void
- Add child form
- addInput() : void
- Add input to form
- addPlugin() : void
- Add plugin
- addScript() : void
- addUnique() : void
- Setup unique combination of columns
- checkKey() : bool
- checkTable() : bool
- delete() : bool
- Deletes selected record and its children
- disableEdit() : void
- Disable inputs in form
- getChildren() : array<string|int, Form>
- Get all dependent forms
- getColOrder() : array<string, Input>
- getCss() : array<string|int, mixed>
- Get css for form and plugins
- getData() : array<string|int, mixed>
- Get data from form
- getErrors() : array<string|int, string>
- Get error list
- getForm() : string
- getForms() : array<string|int, Form>
- Return all form for sync
- getIdent() : string
- getInput() : Input
- Get input
- getInputs() : array<string, Input>
- getInputValue() : string|float|int|null
- Get input value
- getJMark() : string
- Get javascript form var name
- getKey() : string
- getKeyInputs() : array<string|int, Input>
- getKeys() : array<string|int, mixed>
- getKeyValue() : string|int|null
- getOrder() : array<string, string>
- getParent() : Form|null
- Get parent form or null
- getPlugins() : array<string|int, Plugin>
- Get plugins
- getScript() : array<string, mixed>
- getScriptTable() : string
- getTable() : string|null
- Return clear table name or escaped with prefix (default)
- getTableData() : array<string|int, mixed>|null
- getTableKeys() : array<string|int, string|int>
- getTableRowKeys() : array<string|int, string>|array<string|int, int>
- getTableRows() : array<string|int, int>|int
- getType() : int
- Get form type
- getWhere() : string
- hasData() : bool
- Checks if the selected columns have given values
- initTable() : void
- insertForm() : Form
- Force insert/load new form with custom data
- isDeletable() : bool
- isEmpty() : bool
- isInput() : bool
- Check if input exists
- isValid() : bool
- Check input values
- keyInput() : Input
- loadForm() : void
- Load data to form
- loadPost() : int
- Loads POST/GET to inputs
- loadPostMultiple() : bool
- Load POST/GET data for multiple edit
- loadTable() : bool
- Load data for table
- parentInput() : Input
- removeInput() : void
- Remove input from form
- required() : bool
- reset() : void
- Reset only key inputs
- saveForm() : bool
- saveTable() : bool
- Saves changes from actions from table view
- setChildClass() : void
- setChildren() : void
- Set child forms
- setColOrder() : void
- setCount() : void
- Set min and/or max form count
- setData() : void
- Insert data to inputs
- setInputValue() : void
- Set input value
- setKey() : void
- setOrder() : void
- Array could be single or multiple array
- setPresets() : void
- setTemplate() : void
- setUp() : string|int
- setWhere() : void
- switchToMultiple() : void
- Turn on multiple edit / record clone mode
- toString() : string
- translate() : void
- Translate labels and error messages
- createForm() : Form
- dataBind() : void
- Update bound inputs to match current form
- dummyScript() : array<string, mixed>
- getBtnDelete() : string
- getBtnIgnore() : string
- getBtnMulti() : string
- getFormById() : Form|null
- getFormCore() : string
- getFormInputs() : string
- Returns visible form input fields
- getFormMulti() : string
- getFormsByParentId() : array<string|int, Form>
- getFormTemplate() : string
- getMultipleAddon() : string
- Checkbox for group edits
- getScriptConstruct() : string
- getScriptMulti() : array<string, mixed>
- getSubFormClass() : string
- getTableColumns() : array<string|int, array<string|int, object>|object>
- getUniqueCol() : array<string|int, string>
- getUniqueError() : string
- insertDataPreset() : void
- Insert presets data into empty forms, if unique check if already exists
- insertDummy() : void
- isSetDelete() : bool
- Should be subform deleted?
- isUnique() : bool
- loadDuplicates() : void
- loadForeigns() : bool
- queryReplace() : string
- Fill variables for sql requests from Input
- setParent() : void
- tableReplace() : string
- Fill variables for table content from Input
Properties
$blockPara
public
static array{0: string, 1?: string|null, 2?: bool}|null
$blockPara
= ['div', 'row my-2']
$class
public
string|null
$class
= null
$dependents
public
array<int, array<string, mixed>>
$dependents
= []
Tables depending on this one - support for restriction|cascade
$duplicates
public
array<int, array<string, mixed>>
$duplicates
= []
Input duplication
$errors
public
array<string|int, string>
$errors
= []
Error list
$exists
public
bool
$exists
= false
Record already exists
$fixed
public
bool
$fixed
= false
$foreign
public
array<string, array<string, mixed>>
$foreign
= []
Foreign keys
$formChildren
public
array<string|int, Form>
$formChildren
= []
Sub-forms
$forms
public
array<string|int, Form>
$forms
= []
$id
public
string|int
$id
Unique id of current form
$idParent
public
int|null
$idParent
Parent form id
$inputs
public
array<string, Input>
$inputs
= []
Form inputs
$labelPara
public
static string
$labelPara
= 'col-form-label col-md-3'
$legend
public
string|null
$legend
= null
$oldKey
public
mixed
$oldKey
= null
Old key for non-uniques
$parent
public
string|null
$parent
$presets
public
array<string, mixed>|null
$presets
= null
$primary
public
string
$primary
primary column
$purge
public
bool
$purge
= false
Remove all records from DB before saving
$required
public
bool|null
$required
= true
$tableColumns
public
int
$tableColumns
= 0
$type
public
int
$type
Group / form type indent for multiform
$uniqueKey
public
bool
$uniqueKey
= false
primary column is unique identification
$uniques
public
array<string, array<string, mixed>>
$uniques
= []
Unique columns
$changeable
protected
bool
$changeable
= true
$childClass
protected
string
$childClass
= \Form\Forms\TableForm::class
$columnOrder
protected
array<string, bool>
$columnOrder
= []
$data
protected
array<string|int, mixed>
$data
= []
Data inside table
$db
protected
SQL
$db
sql connection
$dummyForms
protected
array<string|int, Form>
$dummyForms
= []
Forms for JS less multiform
$editable
protected
bool
$editable
= true
Allow editing - preview only
$formParent
protected
Form|null
$formParent
= null
Parent form
$jForm
protected
string
$jForm
= 'jTableForm'
$max
protected
int
$max
= 0
$min
protected
int
$min
= 0
$multiple
protected
bool
$multiple
= false
Multiple edit mode
$order
protected
array<string, string>
$order
= []
$plugins
protected
array<string|int, Plugin>
$plugins
= []
$scripts
protected
array<string, mixed>
$scripts
= []
$table
protected
string|null
$table
Table name or null
$template
protected
array<string, string>|null
$template
= null
Custom form design
$where
protected
array<string, mixed>|string|null
$where
Restrictions for which records can be selected
Methods
__construct()
public
__construct(SQL $db, string|null $table, string $primary[, array<string, mixed>|string|null $where = null ]) : mixed
Parameters
- $db : SQL
-
Database connection
- $table : string|null
-
Database table name
- $primary : string
-
Unique column
- $where : array<string, mixed>|string|null = null
__toString()
public
__toString() : mixed
addComment()
Insert comment
public
addComment(string $text[, bool $block = true ]) : void
Parameters
- $text : string
- $block : bool = true
addDependent()
Tables that depend on the primary key of this table
public
addDependent(string $table, array<string, mixed>|string $mixed[, bool $delete = false ][, string|null $error = null ]) : void
Parameters
- $table : string
-
Table name
- $mixed : array<string, mixed>|string
-
Columns|array
- $delete : bool = false
-
Should dependent records be deleted (true) or stop deletion (false)
- $error : string|null = null
-
Optional error message
addDuplicate()
Content of inputs that can be duplicated if the target input is empty
public
addDuplicate(array<string|int, string>|string $from, string $to[, string $type = 'COPY' ]) : void
Parameters
- $from : array<string|int, string>|string
-
source inputs
- $to : string
-
target input
- $type : string = 'COPY'
-
copying method
addForeign()
Foreign key - values
public
addForeign(string $mark, string $table, string $unique, string $col[, array<string|int, mixed>|string $where = null ][, array<string|int, array<string, mixed>|string> $null = [] ][, array<string, mixed>|bool $foreign = false ][, array<string, array<string|int, string>|array<string|int, int>>|null $disable = null ]) : void
Parameters
- $mark : string
-
Input mark
- $table : string
-
Foreign table
- $unique : string
-
Foreign unique key
- $col : string
-
Foreign column
- $where : array<string|int, mixed>|string = null
-
Restriction for selection of records from foreign table
- $null : array<string|int, array<string, mixed>|string> = []
-
Null value
- $foreign : array<string, mixed>|bool = false
-
Limited to lines for specific key (multiple records)
- $disable : array<string, array<string|int, string>|array<string|int, int>>|null = null
Tags
addForm()
Add child form
public
addForm(Form $form) : void
Parameters
- $form : Form
addInput()
Add input to form
public
addInput(Input $input) : void
Parameters
- $input : Input
Tags
addPlugin()
Add plugin
public
addPlugin(Plugin $plugin) : void
Parameters
- $plugin : Plugin
addScript()
public
addScript(array<string, mixed>|string $script[, string $type = 'FORM' ]) : void
Parameters
- $script : array<string, mixed>|string
- $type : string = 'FORM'
addUnique()
Setup unique combination of columns
public
addUnique(array<string|int, Input|string>|Input|string $array[, string|null $error = null ]) : void
Parameters
checkKey()
public
checkKey(string|int $key[, int|null $parentId = null ]) : bool
Parameters
- $key : string|int
- $parentId : int|null = null
Return values
boolcheckTable()
public
checkTable(array<string, mixed> $row) : bool
Parameters
- $row : array<string, mixed>
Return values
booldelete()
Deletes selected record and its children
public
delete([string|float|int|null $key = null ]) : bool
Parameters
- $key : string|float|int|null = null
Return values
booldisableEdit()
Disable inputs in form
public
disableEdit([string $mode = 'read' ][, bool $save = false ]) : void
Parameters
- $mode : string = 'read'
- $save : bool = false
getChildren()
Get all dependent forms
public
getChildren() : array<string|int, Form>
Return values
array<string|int, Form>getColOrder()
public
getColOrder() : array<string, Input>
Return values
array<string, Input>getCss()
Get css for form and plugins
public
getCss() : array<string|int, mixed>
Return values
array<string|int, mixed>getData()
Get data from form
public
getData() : array<string|int, mixed>
Return values
array<string|int, mixed>getErrors()
Get error list
public
getErrors() : array<string|int, string>
Return values
array<string|int, string>getForm()
public
getForm(string|int $parentId[, bool $dummy = false ][, array<string|int, Form> $ignores = [] ]) : string
Parameters
- $parentId : string|int
- $dummy : bool = false
- $ignores : array<string|int, Form> = []
Return values
stringgetForms()
Return all form for sync
public
getForms([int|null $childTypeId = null ]) : array<string|int, Form>
Parameters
- $childTypeId : int|null = null
Return values
array<string|int, Form>getIdent()
public
getIdent() : string
Return values
stringgetInput()
Get input
public
& getInput(string $mark) : Input
Parameters
- $mark : string
Return values
InputgetInputs()
public
getInputs([bool $all = false ]) : array<string, Input>
Parameters
- $all : bool = false
Return values
array<string, Input>getInputValue()
Get input value
public
getInputValue(string $mark) : string|float|int|null
Parameters
- $mark : string
Tags
Return values
string|float|int|nullgetJMark()
Get javascript form var name
public
getJMark() : string
Return values
stringgetKey()
public
getKey([string $join = 'AND' ]) : string
Parameters
- $join : string = 'AND'
Return values
stringgetKeyInputs()
public
getKeyInputs() : array<string|int, Input>
Return values
array<string|int, Input>getKeys()
public
getKeys([bool $escape = true ]) : array<string|int, mixed>
Parameters
- $escape : bool = true
Return values
array<string|int, mixed>getKeyValue()
public
getKeyValue() : string|int|null
Return values
string|int|nullgetOrder()
public
getOrder() : array<string, string>
Return values
array<string, string>getParent()
Get parent form or null
public
getParent() : Form|null
Return values
Form|nullgetPlugins()
Get plugins
public
getPlugins() : array<string|int, Plugin>
Return values
array<string|int, Plugin>getScript()
public
getScript(string $jParent[, bool $dummy = false ]) : array<string, mixed>
Parameters
- $jParent : string
- $dummy : bool = false
Return values
array<string, mixed>getScriptTable()
public
getScriptTable() : string
Return values
stringgetTable()
Return clear table name or escaped with prefix (default)
public
getTable([bool $escape = true ]) : string|null
Parameters
- $escape : bool = true
Return values
string|nullgetTableData()
public
getTableData(array<string|int, string|int> $ids[, bool $clean = false ]) : array<string|int, mixed>|null
Parameters
- $ids : array<string|int, string|int>
-
Row ids
- $clean : bool = false
-
Are data for table or export
Return values
array<string|int, mixed>|nullgetTableKeys()
public
getTableKeys([array<string|int, string|int>|null $find = null ][, Form|null $childForm = null ]) : array<string|int, string|int>
Parameters
- $find : array<string|int, string|int>|null = null
- $childForm : Form|null = null
Return values
array<string|int, string|int>getTableRowKeys()
public
getTableRowKeys(array<string|int, string> $parent) : array<string|int, string>|array<string|int, int>
Parameters
- $parent : array<string|int, string>
Return values
array<string|int, string>|array<string|int, int>getTableRows()
public
getTableRows(array<string|int, string|int> $ids[, bool $array = false ][, bool $reverse = false ]) : array<string|int, int>|int
Parameters
- $ids : array<string|int, string|int>
- $array : bool = false
- $reverse : bool = false
Return values
array<string|int, int>|intgetType()
Get form type
public
getType() : int
Return values
intgetWhere()
public
getWhere([string $pre = '' ][, bool $edit = true ][, string|null $alias = null ]) : string
Parameters
- $pre : string = ''
- $edit : bool = true
-
true for edit / false for filtered view
- $alias : string|null = null
Return values
stringhasData()
Checks if the selected columns have given values
public
hasData(array<string, mixed> $array) : bool
Parameters
- $array : array<string, mixed>
Return values
boolinitTable()
public
initTable() : void
insertForm()
Force insert/load new form with custom data
public
insertForm(string|int $id[, array<string, mixed> $data = null ][, int|null $parentId = null ][, bool $exists = true ]) : Form
Parameters
- $id : string|int
- $data : array<string, mixed> = null
- $parentId : int|null = null
- $exists : bool = true
Return values
FormisDeletable()
public
isDeletable() : bool
Return values
boolisEmpty()
public
isEmpty([array<string|int, string> $ignore = [] ]) : bool
Parameters
- $ignore : array<string|int, string> = []
Return values
boolisInput()
Check if input exists
public
isInput(string $mark) : bool
Parameters
- $mark : string
Return values
boolisValid()
Check input values
public
isValid([bool $uniques = true ]) : bool
Parameters
- $uniques : bool = true
Return values
boolkeyInput()
public
& keyInput() : Input
Return values
InputloadForm()
Load data to form
public
loadForm() : void
Tags
loadPost()
Loads POST/GET to inputs
public
loadPost(int $maxId[, bool $clone = false ]) : int
Parameters
- $maxId : int
- $clone : bool = false
Return values
intloadPostMultiple()
Load POST/GET data for multiple edit
public
loadPostMultiple() : bool
Return values
boolloadTable()
Load data for table
public
loadTable(array<string|int, string|int> $list[, string|null $where = null ]) : bool
Parameters
- $list : array<string|int, string|int>
- $where : string|null = null
Return values
boolparentInput()
public
& parentInput() : Input
Return values
InputremoveInput()
Remove input from form
public
removeInput(string $mark) : void
Parameters
- $mark : string
Tags
required()
public
required() : bool
Return values
boolreset()
Reset only key inputs
public
reset() : void
saveForm()
public
saveForm([int|null $parentId = null ]) : bool
Parameters
- $parentId : int|null = null
Return values
boolsaveTable()
Saves changes from actions from table view
public
saveTable(string|int $id, string $mark, mixed $action) : bool
Parameters
- $id : string|int
- $mark : string
- $action : mixed
Return values
boolsetChildClass()
public
setChildClass(string $class) : void
Parameters
- $class : string
setChildren()
Set child forms
public
setChildren(array<string|int, Form> $children) : void
Parameters
- $children : array<string|int, Form>
setColOrder()
public
setColOrder(array<string|int, string> $order) : void
Parameters
- $order : array<string|int, string>
Tags
setCount()
Set min and/or max form count
public
setCount(array<string, int|bool>|int $sets) : void
Parameters
- $sets : array<string, int|bool>|int
setData()
Insert data to inputs
public
setData(array<string, mixed> $array[, bool $force = false ]) : void
Parameters
- $array : array<string, mixed>
- $force : bool = false
setInputValue()
Set input value
public
setInputValue(string $mark, mixed $value) : void
Parameters
- $mark : string
- $value : mixed
Tags
setKey()
public
setKey(string|int|null $id[, string|int|null $parentId = null ][, bool $check = true ]) : void
Parameters
- $id : string|int|null
- $parentId : string|int|null = null
- $check : bool = true
setOrder()
Array could be single or multiple array
public
setOrder(array<string|int, Input, WAY: string}>|Input, WAY: string} $array) : void
Parameters
- $array : array<string|int, Input, WAY: string}>|Input, WAY: string}
Tags
setPresets()
public
setPresets(array<int, array<string, mixed>> $presets[, bool $unique = true ]) : void
Parameters
- $presets : array<int, array<string, mixed>>
- $unique : bool = true
Tags
setTemplate()
public
setTemplate(string|null $template[, string $type = 'FORM' ]) : void
Parameters
- $template : string|null
- $type : string = 'FORM'
setUp()
public
setUp(string|int $id, int $type[, bool|null $foreign = null ][, bool $edit = true ]) : string|int
Parameters
- $id : string|int
- $type : int
- $foreign : bool|null = null
- $edit : bool = true
Return values
string|intsetWhere()
public
setWhere(array<string, mixed>|string|null $where[, string|null $type = null ]) : void
Parameters
- $where : array<string, mixed>|string|null
- $type : string|null = null
switchToMultiple()
Turn on multiple edit / record clone mode
public
switchToMultiple() : void
toString()
public
toString([bool $comments = true ][, bool $hidden = false ]) : string
Parameters
- $comments : bool = true
- $hidden : bool = false
Return values
stringtranslate()
Translate labels and error messages
public
translate(Translator $tr) : void
Parameters
- $tr : Translator
createForm()
protected
createForm([Form|null $form = null ]) : Form
Parameters
- $form : Form|null = null
Return values
FormdataBind()
Update bound inputs to match current form
protected
dataBind() : void
Tags
dummyScript()
protected
dummyScript(string $jForm) : array<string, mixed>
Parameters
- $jForm : string
Return values
array<string, mixed>getBtnDelete()
protected
getBtnDelete(Form $form[, string|null $title = null ]) : string
Parameters
- $form : Form
- $title : string|null = null
Return values
stringgetBtnIgnore()
protected
getBtnIgnore(Form $form[, string|null $title = null ]) : string
Parameters
- $form : Form
- $title : string|null = null
Return values
stringgetBtnMulti()
protected
getBtnMulti(string|int $parentId) : string
Parameters
- $parentId : string|int
Return values
stringgetFormById()
protected
getFormById(int $id) : Form|null
Parameters
- $id : int
Return values
Form|nullgetFormCore()
protected
final getFormCore(string|int $parentId, bool $dummy) : string
Parameters
- $parentId : string|int
- $dummy : bool
Return values
stringgetFormInputs()
Returns visible form input fields
protected
getFormInputs() : string
Return values
stringgetFormMulti()
protected
getFormMulti(mixed $parent[, bool $dummy = false ][, array<string|int, mixed> $ignores = [] ]) : string
Parameters
- $parent : mixed
- $dummy : bool = false
- $ignores : array<string|int, mixed> = []
Return values
stringgetFormsByParentId()
protected
getFormsByParentId(int|null $parentId) : array<string|int, Form>
Parameters
- $parentId : int|null
Return values
array<string|int, Form>getFormTemplate()
protected
getFormTemplate(string $template, bool $dummy, array<string|int, Form> $ignores[, bool $edit = true ]) : string
Parameters
- $template : string
- $dummy : bool
- $ignores : array<string|int, Form>
- $edit : bool = true
Tags
Return values
stringgetMultipleAddon()
Checkbox for group edits
protected
final getMultipleAddon(string $mark, string|int $id) : string
Parameters
- $mark : string
- $id : string|int
Return values
stringgetScriptConstruct()
protected
getScriptConstruct(string $mark[, array<string, mixed> $para = [] ]) : string
Parameters
- $mark : string
- $para : array<string, mixed> = []
Return values
stringgetScriptMulti()
protected
getScriptMulti(string $parent, bool $dummy[, array<string|int, mixed> $para = [] ]) : array<string, mixed>
Parameters
- $parent : string
- $dummy : bool
- $para : array<string|int, mixed> = []
Return values
array<string, mixed>getSubFormClass()
protected
getSubFormClass([Form $form = null ]) : string
Parameters
- $form : Form = null
Return values
stringgetTableColumns()
protected
getTableColumns(array<string, mixed> $data[, bool $clean = false ]) : array<string|int, array<string|int, object>|object>
Parameters
- $data : array<string, mixed>
- $clean : bool = false
Return values
array<string|int, array<string|int, object>|object>getUniqueCol()
protected
getUniqueCol(array<string, string> &$tables, Form $form, array<string|int, Input|string> $cols) : array<string|int, string>
Parameters
Return values
array<string|int, string>getUniqueError()
protected
getUniqueError(array<string, mixed> $array) : string
Parameters
- $array : array<string, mixed>
Return values
stringinsertDataPreset()
Insert presets data into empty forms, if unique check if already exists
protected
insertDataPreset() : void
insertDummy()
protected
insertDummy(int $count, int|null $parentId) : void
Parameters
- $count : int
- $parentId : int|null
isSetDelete()
Should be subform deleted?
protected
isSetDelete(Form $form) : bool
Parameters
- $form : Form
Return values
boolisUnique()
protected
isUnique(array<string|int, Input|string> $cols) : bool
Parameters
- $cols : array<string|int, Input|string>
Return values
boolloadDuplicates()
protected
loadDuplicates() : void
loadForeigns()
protected
loadForeigns(bool $edit[, bool $load = true ]) : bool
Parameters
- $edit : bool
- $load : bool = true
Return values
boolqueryReplace()
Fill variables for sql requests from Input
protected
queryReplace(string $string, string $mark) : string
Parameters
- $string : string
- $mark : string
Return values
stringsetParent()
protected
setParent(Form $parent) : void
Parameters
- $parent : Form
tableReplace()
Fill variables for table content from Input
protected
tableReplace(string $string) : string
Parameters
- $string : string