Class WPDA_Simple_Form_Item

Simple forms consist of items. Items correspond with table columns. Basically an item is generated for every table column in the base table. Class WPDA_Simple_Form_Item handles a database column as a standard text item.

It's possible to add dummy columns. Values for dummy columns however are lost when data is saved.

Check out \WPDataAccess\Simple_Form\WPDA_Simple_Form to see how to use simple form items.

author Peter Schulz
since 1.0.0
package WPDataAccess\Simple_Form

 Methods

WPDA_Simple_Form_Item constructor

__construct(array $args = array()

Declare item with all its properties.

since 1.0.0

Parameters

$args

array

[

'item_name' => item name

'data_type' => data type

'item_label' => label

'item_value' => value (in database)

'item_default_value' => default value

'item_extra' => check column extra in information_schema.columns

'item_enum' => enum (if applicable)

'item_enum_options' => enum options (if applicable)

'column_type' => type

'item_event' => JS event(s)

'item_js' => JS code (global)

'item_hide_icon' => icon (showing data type)

'item_class' => css class

'hide_item' => item visibility

'is_nullable' => allow null values?

'is_key_column' => is key column?

].

Get column type

get_column_type() : string
since 1.0.0

Returns

string

Get item data type

get_data_type() : string
since 1.0.0

Returns

string

Get item visibility

get_hide_item() : boolean
since 1.6.9

Returns

boolean

Get item CSS class

get_item_class() : string
since 1.0.0

Returns

string

Get item default value

get_item_default_value() : mixed
since 1.0.0

Returns

mixed

Get enum values or empty

get_item_enum() : array
since 1.0.0

Returns

array

Get enum options or empty

get_item_enum_options() : array
since 1.6.9

Returns

array

Get item event

get_item_event() : String
since 1.0.0

Returns

String

Get item 'extra' info

get_item_extra() : mixed

Hide icon?

get_item_hide_icon() : boolean
since 1.0.0

Returns

boolean

Get item Javascript code

get_item_js() : mixed
since 1.0.0

Returns

mixed

Get item label

get_item_label() : string
since 1.0.0

Returns

string

Het item name

get_item_name() : string
since 1.0.0

Returns

string

Get item value

get_item_value() : mixed
since 1.0.0

Returns

mixed

Null values allowed?

is_key_column() : boolean
since 2.0.0

Returns

boolean

Null values allowed?

is_nullable() : boolean
since 2.0.0

Returns

boolean

Check if item is valid

is_valid($pre_insert = false) : boolean

Parameters

$pre_insert

Returns

boolean

Set item data_type

set_data_type(string $data_type) 
since 1.6.9

Parameters

$data_type

string

Item data type

Set item enum

set_enum(string $item_enum) 
since 1.6.9

Parameters

$item_enum

string

Item enum value list

Set item enum options

set_enum_options(string $item_enum_options) 
since 1.6.9

Parameters

$item_enum_options

string

Item enum option list

Set item visibility

set_hide_item(boolean $hide_item) 
since 1.6.9

Parameters

$hide_item

boolean

TRUE = hide item

Set item is key column

set_is_key_column(boolean $is_key_column) 

Parameters

$is_key_column

boolean

TRUE|FALSE

Set item CSS class

set_item_class(string $item_class) 
since 1.6.2

Parameters

$item_class

string

HTML class name

Set item default value

set_item_default_value(string $item_default_value) 
since 1.6.2

Parameters

$item_default_value

string

Default value

Set item visibility

set_item_hide_icon(boolean $item_hide_icon) 
since 2.0.8

Parameters

$item_hide_icon

boolean

TRUE = hide type icon behind text field

Set item js code

set_item_js(string $item_js) 
since 1.6.9

Parameters

$item_js

string

Item specific javascript code

Item value

set_item_value(string $value) 

Parameters

$value

string

Item value

Item label

set_label(string $label) 

Parameters

$label

string

Item label

Show item row

show(string $action, string $update_keys_allowed) 

Parameters

$action

string

Requested action

$update_keys_allowed

string

TRUE = allow key updates

Displays default text item

show_item() 

Overwrite this method to define specific item processing like enum, set, image and so on.

 Properties

 

Database column type

$column_type : string

Default

Column type offers more info than data type, like column length or values for enum types.

 

MySQL data type

$data_type : string

Default

 

TRUE = item not shown, FALSE = item shown

$hide_item : boolean

Default

 

TRUE = is auto_increment column

$is_auto_increment : boolean

Default

false
 

TRUE = column is part of primary key, FALSE = column is not part of primary key

$is_key_column : boolean

Default

 

TRUE = null values are allowed, FALSE = no null values allowed

$is_nullable : boolean

Default

 

Item CSS class

$item_class : string

Default

 

Default value

$item_default_value : mixed

Default

 

Enum values for column or empty

$item_enum : array

Default

 

Enum options for column or empty

$item_enum_options : array

Default

 

Array of events

$item_event : array

Default

Add event to item for example: ["onclick" => "check_item_value()"]

 

Database column specific info

$item_extra : string

Default

Like auto_increment, on update, etc

 

Show item icon (data type)

$item_hide_icon : boolean

Default

TRUE = icon is shown after item, FALSE = hide icon (default FALSE)

 

Icon type

$item_icon_type : string

Default

 

Item specific Javascript code

$item_js : string

Default

Code is added to the end of the form.

 

Item label

$item_label : string

Default

 

Database column name

$item_name : string

Default

 

Item placeholder

$item_placeholder : string

Default

''
 

Current column value in the database

$item_value : mixed

Default

 

Context variable to keep logic for showing items maintainable

$show_context_action : string

Default

 

Context variable to keep logic for showing items maintainable

$show_context_class_primary_key : string

Default

 

Context variable to keep logic for showing items maintainable

$show_context_column_value : string

Default

 

Context variable to keep logic for showing items maintainable

$show_context_item_events : string

Default

 

Context variable to keep logic for showing items maintainable

$show_context_update_keys_allowed : string

Default