MultiEdit
in package
UI system for rapid adding/editing of any number of (sub-)records
Tags
Table of Contents
Properties
- $init_item : mixed
- $item_name : mixed
- $post_add_func : mixed
- $reorder : mixed
Methods
- display() : mixed
- Displays a multiedit field
- initItem() : void
- Include a initial empty item.
- itemName() : mixed
- Set the item name for a multiedit.
- load() : array<int, array<string, mixed>>
- Returns an array of data, which should be put into a view, and passed into MultiEdit::display.
- recordEmpty() : bool
- Returns true if the multiedit record is empty, false otherwise
- reorder() : mixed
- Enable multiedit reordering
- setPostAddJavaScriptFunc() : mixed
- Set the name of a javascript function to call after each multiedit item is added
Properties
$init_item
private
static mixed
$init_item
= true
$item_name
private
static mixed
$item_name
= null
$post_add_func
private
static mixed
$post_add_func
= null
$reorder
private
static mixed
$reorder
= false
Methods
display()
Displays a multiedit field
public
static display(string $key, array<string|int, mixed>|null $data[, array<string|int, mixed> $errors = [] ]) : mixed
Parameters
- $key : string
-
Key to group records for this multiedit
- $data : array<string|int, mixed>|null
-
Records from DB or session
- $errors : array<string|int, mixed> = []
-
Error messages, in the format [ index => [field => msg] ]
initItem()
Include a initial empty item.
public
static initItem(bool $set) : void
Parameters
- $set : bool
itemName()
Set the item name for a multiedit.
public
static itemName(mixed $item_name) : mixed
e.g. 'image'
Parameters
- $item_name : mixed
load()
Returns an array of data, which should be put into a view, and passed into MultiEdit::display.
public
static load(string $table[, array<string|int, mixed> $where = [] ][, string|array<string|int, mixed> $order = 'id' ]) : array<int, array<string, mixed>>
Parameters
- $table : string
-
Table to load data from
- $where : array<string|int, mixed> = []
-
Conditions for WHERE clause, as per Pdb::buildClause
- $order : string|array<string|int, mixed> = 'id'
-
Column(s) to order records by
Return values
array<int, array<string, mixed>> —Each element is a row
recordEmpty()
Returns true if the multiedit record is empty, false otherwise
public
static recordEmpty(array<string|int, mixed> $record[, array<string|int, mixed> $defaults = [] ]) : bool
Parameters
- $record : array<string|int, mixed>
-
Collated [field => value] pairs which are to be saved with a multiedit record
- $defaults : array<string|int, mixed> = []
-
Default values as [field => value] pairs; any field which is set to its default value isn't counted as non-empty; i.e. if all fields are left as their default values, the record is considered empty.
Return values
boolreorder()
Enable multiedit reordering
public
static reorder() : mixed
setPostAddJavaScriptFunc()
Set the name of a javascript function to call after each multiedit item is added
public
static setPostAddJavaScriptFunc(string $function_name) : mixed
The JavaScript function is called with the following arguments: $div jQuery element for the outer div data Array of field data OR null for a new record idx The record index
Parameters
- $function_name : string