Class WPDP_Project_Page_Form extends WPDP_Child_Form

Uses table options to hide items and add lookups to data entry form

see \WPDataProjects\Parent_Child\WPDP_Child_Form
author Peter Schulz
since 2.0.0
package WPDataProjects\Project
inherited_from \WPDataProjects\Parent_Child\WPDP_Child_Form

 Methods

WPDP_Project_Page_Form constructor.

__construct(string $schema_name, string $table_name, \WPDataAccess\Data_Dictionary\WPDA_List_Columns $wpda_list_columns, array $args = array()

Performs the following steps:

  • Check if requested action is allowed
  • Check if table is provided
  • Save OLD and NEW request values
  • Create WPDA_Simple_Form_Data object
inherited_from \WPDataProjects\Parent_Child\WPDP_Child_Form::__construct()

Parameters

$schema_name

$table_name

$wpda_list_columns

$args

array

WPDA_Simple_Form constructor

__construct(string $schema_name, string $table_name, \WPDataAccess\Data_Dictionary\WPDA_List_Columns $wpda_list_columns, array $args = array()
Inherited

Performs the following steps:

  • Check if requested action is allowed
  • Check if table is provided
  • Save OLD and NEW request values
  • Create WPDA_Simple_Form_Data object
since 1.0.0
see \WPDataAccess\Simple_Form\WPDA_Simple_Form_Data

Parameters

$schema_name

string

Database schema name.

$table_name

string

Database table name.

$wpda_list_columns

\WPDataAccess\Data_Dictionary\WPDA_List_Columns

Reference to column array.

$args

array

Messages (named array).

Overwrite to add buttons to right bottom

add_buttons() 
Inherited
since 2.0.15

Overwrite to add logic to form

add_form_logic() 
Inherited
since 2.0.15

Number of items

count() : integer
Inherited
since 2.0.15

Returns

integer

Get primary form action

get_form_action() : string
Inherited
since 1.0.0

Returns

stringPrimary page action

Get secondary form action

get_form_action2() : string
Inherited
since 1.0.0

Returns

stringSecondary page action

Get new value for item

get_new_value(string $column_name) : mixed | string
Inherited

Or empty if no new value available.

since 1.0.0

Parameters

$column_name

string

Column name.

Returns

mixedstringNew value for column or empty.

Get old value form item

get_old_value(string $column_name) : mixed | string
Inherited

Or empty if no old value available.

since 1.0.0

Parameters

$column_name

string

Column name.

Returns

mixedstringOld value for column or empty.

Hide items

hide_items(array $items_to_hide) 
Inherited
since 2.0.15

Parameters

$items_to_hide

array

Arrays contains item names of items that should be defined as hidden

Set item labels

set_labels(array $item_labels) 
Inherited
since 2.0.15

Parameters

$item_labels

array

Named array containing item name/label pairs

Overwrites method show

show(boolean $allow_save = true, string $add_param = ''

Parameters

$allow_save

boolean

$add_param

string

Show simple form

show(boolean $allow_save = true, string $add_param = ''
Inherited

Performs the following steps:

  • Checks for posted data
  • Saves changes if applicable (displays success or failure message)
  • Prepares simple form
  • Shows simple form for requested table (HTML ande Javascript)
since 1.0.0

Parameters

$allow_save

boolean

Allow to save data

$add_param

string

Parameter to be added to form action.

Add dummy column to form

add_dummy_column(string $column_name) 
Inherited
since 1.0.0

Parameters

$column_name

string

Column name.

Add item to form

add_form_item(integer $index, \WPDataAccess\Simple_Form\WPDA_Simple_Form_Item $item) 
Inherited
since 1.0.0
see \WPDataAccess\Simple_Form\WPDA_Simple_Form_Item

Parameters

$index

integer

Item sequence number.

$item

\WPDataAccess\Simple_Form\WPDA_Simple_Form_Item

Reference to simple form item.

Use this method to build parent child relationships.

add_parent_args() 
Inherited

Overwrite this function if you want to use the form as a child form related to some parent form. You can add parent arguments to calls to make sure you get back to the right parent.

since 1.5.0

Use this method to build parent child relationships.

add_parent_args_to_back_button() 
Inherited

Overwrite this function if you want to use the form as a child form related to some parent form. You can add parent arguments to calls to make sure you get back to the right parent.

since 1.6.9

Get all db tables and views

get_all_db_tables(string $database) : array

Parameters

$database

string

Database schema name

Returns

array

Get actual child tab

get_child_tab() : string
Inherited

Returns

string

Get column position in column array

get_column_position(array $column_array = array(), string $column_name) : integer
Inherited
since 1.0.0

Parameters

$column_array

array

Column array.

$column_name

string

Column name.

Returns

integerPosition of $column_name in $column_array

Get item position

get_item_index(string $item_name) : boolean | integer
Inherited
since 2.0.15

Parameters

$item_name

string

Form item name

Returns

booleanintegerPosition item or false if not found

Creates a wpnonce action

get_nonce_action(boolean $use_old_value = true) : string
Inherited

Set wp_nonce action for security check: prefix + table name + primary key values

since 1.0.0

Parameters

$use_old_value

boolean

TRUE = use old key values, FALSE = use new key values.

Returns

stringwp_nonce action holding: prefix + table name + primary key values.

Get URL arguments.

get_url_arguments() 
Inherited
since 1.5.0

Is column part of primary key?

is_key_column(string $column_name) : boolean
Inherited
since 1.0.0

Parameters

$column_name

string

Column name.

Returns

booleanTRUE = column is part of primary key, FALSE = column is not part of primary key.

Reorder columns

order_and_filter_columns(array $columns_ordered) 
Inherited

Reorders the column array in the order as defined in argument $columns_ordered.

since 1.0.0

Parameters

$columns_ordered

array

Ordered column names.

prepare_form()

prepare_form($allow_save = true
Inherited

Parameters

$allow_save

Overwrites method prepare_items for specific user interaction

prepare_items(boolean $set_back_form_values = false

Uses table options to hide items and add lookups to data entry form

inherited_from \WPDataProjects\Parent_Child\WPDP_Child_Form::prepare_items()

Parameters

$set_back_form_values

boolean

Set item attributes

prepare_items(boolean $set_back_form_values = false
Inherited

If you want to change the layout of your simple form(s), consider to extend class WPDA_Simple_Form and override this method.

since 1.0.0

Parameters

$set_back_form_values

boolean

TRUE = set back user entered value, FALSE = set to database value.

Get current from database table

prepare_row() 
Inherited

Handle insert, update and save diffently.

since 1.0.0

Message shown on insert error

relationship_insert_failed() 
Inherited

Set message number and text

set_message(string $wpda_err, string $wpda_msg) 
Inherited

Assigns values to $this->wpda_err and $this->wpda_msg.

since 1.0.0

Parameters

$wpda_err

string

'0' = INFO, '1' = ERROR.

$wpda_msg

string

Message to be displayed.

Defines whether primary key item can be updated

set_update_keys(boolean $update_keys_allowed) 
Inherited
since 1.0.0

Parameters

$update_keys_allowed

boolean

Allow keys to be updated.

Perform validation check

validate(boolean $pre_insert = false) : boolean
Inherited

Called to perform default validation before insert and update.

Extend class WPDA_Simple_Form and override this method if you need validation on insert and/or update or if you prefer to change error messages. If you want to handle inserts and updates differently, the following information might be helpful:

  • on insert: $this->action = 'new'
  • on update: $this->action = 'edit'

Use set_message to show messages (info as well as error).

since 1.0.0

Parameters

$pre_insert

boolean

Do not check auto_increment during pre-insert

Returns

booleanTRUE = validation succeeded, FALSE = validation failed.

 Properties

 

Primary page action

$action : string

Default

 

Secondary page action

$action2 : string

Default

''
 

Add action to page title?

$add_action_to_title : string

Default

 

Auto increment value

$auto_increment_value : integer

Default

-1
 

Used to changed button text

$back_to_list_text : string

Default

''
 

Indicates whether table type should be checked to display subtitle.

$check_table_type : boolean

Default

true
 

Child relationships (for actual parent)

$child : array

Default

 

Column headers (labels, arguments)

$column_headers : array

Default

 

Form id

$current_form_id : integer

Default

 

$database_tables

$database_tables 

Default

array()
 

Page fieldset title

$fieldset_title : string

Default

''
 

Static id to create unique form names on the page

$form_id : integer

Default

0
Static
 

Form items

$form_items : array

Default

array()
 

Form items named array

$form_items_named : array

Default

array()

Use this array to quickly find an item in the form

 

Form items new values (if applicable)

$form_items_new_values : array

Default

array()
 

Form items old values (if applicable)

$form_items_old_values : array

Default

array()
 

Show help icon if hrlp url is available

$help_url : null | string

Default

null
 

Hide Add New button

$hide_add_new : null | string

Default

false
 

Saved initially requested action

$initial_action : string

Default

Action is changed during processing

 

Possible values: edit and view

$mode : string

Default

 

Hides warning update text

$no_warning_update_text : string

Default

'FALSE'
 

Menu slug current page

$page : string

Default

 

Page number text item

$page_number_item : null

Default

''
 

Page number item name (default 'page_number')

$page_number_item_name : string

Default

'page_number'

The name can be changed for pages on multiple levels. This is needed to get back to the right page in parent-child page.

   

Parent key values

$parent : array

Default

 

Handle to database record

$row : object

Default

 

Handle to data management component

$row_data : \WPDataAccess\Simple_Form\WPDA_Simple_Form_Data

Default

 

Database schema name

$schema_name : string

Default

 

Options set name

$setname : string

Default

'default'
 

Indicates whether the back button should be displayed or not

$show_back_button : boolean

Default

true
 

Indicates whether the back icon in the title should be displayed or not

$show_back_icon : boolean

Default

true
 

Indicates whether the title should be displayed or not

$show_title : boolean

Default

true
 

Page subtitle

$subtitle : string

Default

''
 

Display column headers

$table_column_header : array

Default

 

Access column headers

$table_column_headers : array

Default

 

Access column names

$table_columns : array

Default

 

Database table name

$table_name : string

Default

 

Page title

$title : string

Default

null
 

Defines it keys are updatable

$update_keys_allowed : boolean

Default

false
 

Error message number

$wpda_err : integer

Default

0
 

Handle to WPDA_List_Columns

$wpda_list_columns : \WPDataAccess\Data_Dictionary\WPDA_List_Columns

Default

 

Error message text

$wpda_msg : string

Default

''
 

Table settings (taken from plugin table settings table)

$wpda_table_settings : mixed | null

Default

null

 Constants

 

Warning icon

WARNING_ICON = '<span class="dashicons dashicons-warning"></span> '