Properties

$form_property

$form_property

$form_width

$form_width

$form_height

$form_height

$border

$border

$pk

$pk

Methods

set_label()

set_label(mixed $col, mixed $label) : $this

Set form element label

Parameters

mixed $col
  • Database table column name
mixed $label
  • Label

Returns

$this

set_dimension()

set_dimension(mixed $col, int $cols, int $rows) : $this

Set control dimension width and height. Note that this is not the same as set_form_dimension().

It is used with text type only. For column type text, the width is translated to "size", its height is ignored. for text area, the width is translated to "cols" and height to "rows"

Parameters

mixed $col
  • Database table column name
int $cols
  • If the column is a text box, it’s the size that represents number of characters. If the column is a textarea, it’s the value for cols attribute in textarea.
int $rows
  • Optional. Number of rows in a textarea (only)

Returns

$this

set_form_dimension()

set_form_dimension(mixed $f_width, string $f_height) : $this|void

Set form width and height. Overwrites parent definition for template.

Parameters

mixed $f_width
  • Form width
string $f_height
  • Form height

Returns

$this|void

set_default()

set_default(mixed $col, string $default) : $this

Set control default value on the form

Parameters

mixed $col
  • Database table column name
string $default
  • Default value

Returns

$this

set_readonly()

set_readonly(array $cols) : $this

Set one more more columns as read only field

Parameters

array $cols
  • Column name(s)

Returns

$this

set_required()

set_required(array $cols) : $this

Parameters

array $cols
  • Columns name(s)

Returns

$this

set_hide()

set_hide(mixed $col) : $this

Hide a field on the form from displaying with CSS display:none. Note that the field still exists on the form but not visible.

Do not use this field to hide sensitive information such as password.

Parameters

mixed $col
  • Database table column name

Returns

$this

set_placeholder()

set_placeholder(mixed $col, mixed $ph_text) : $this

Placeholder text for HTML form element.

Parameters

mixed $col
  • Database table column name
mixed $ph_text
  • Placeholder text

Returns

$this

set_border()

set_border(mixed $border_style) : $this

Set form border using CSS stylesheet

Parameters

mixed $border_style
  • border style in CSS

Returns

$this

set_ctrltype()

set_ctrltype(mixed $col, mixed $ctrltype, null $keyvalue_pair, bool $multiple) : $this

Set HTML control type of a specific field. Select and Textare control types are automatically determined by the database field char type based on its length. But you can set it otherwise.

Parameters

mixed $col
  • Database table column name
mixed $ctrltype
  • HTML control type. Supported types:
       text

    textarea select checkbox passwords button autocomplete

       wysiwyg
null $keyvalue_pair
  • Key value pair or SQL SELECT(select control type only)
bool $multiple
  • Multiple select (select control type only)

Returns

$this

set_maxlength()

set_maxlength( $col,  $maxlength)

Parameters

$col
$maxlength

set_editrule()

set_editrule(mixed $col, mixed $rule_func) : $this

Parameters

mixed $col
  • Column name
mixed $rule_func
  • Data rule validation JavaScript

Returns

$this

display_script_includeonce()

display_script_includeonce()

Only include the header scripts once.

display()

display(bool $render_content)

Display our database form

Parameters

bool $render_content
  • Whether to display the form or hold it in PHP buffer to be displayed later.

load_form()

load_form(int $k) : $this

Load an existing entry from DB. If parameter is omitted or set to 0, the first record will be loaded

Parameters

int $k
  • A database table primary key value. Zero to load the very entry.

Returns

$this

redirect_after_submit()

redirect_after_submit(mixed $url) : $this

Redirect form after submit. It does not check whether the submit is success.

Parameters

mixed $url
  • Redirect URL

Returns

$this

add_group_header()

add_group_header(mixed $before_col, mixed $header) : $this

Add caption to a subgroup

Parameters

mixed $before_col
  • column name that caption goes BEFORE
mixed $header
  • caption

Returns

$this

add_captcha()

add_captcha() : $this

Add CAPTCHA (“Completely Automated Public Turing test to tell Computers and Humans Apart”), a type of challenge-response test used in computing to determine whether or not the user is human.

phpDatabaseForm uses realperson jQuery plugin available under MIT license.

Returns

$this

set_mask()

set_mask(mixed $col, mixed $mask, string $extra_prop)

Provides a general format to text field and enforce it's structure as the user types in values.

It gives the user an idea about how they should enter the data.

phpDatabaseForm uses jQuery Mask Input created by Igor Escobar http://igorescobar.github.io/jQuery-Mask-Plugin/ available under MIT license.

Parameters

mixed $col
  • Column name
mixed $mask
  • Mask pattern
string $extra_prop
  • Optional. Addition properties e.g. "{placeholder: '(_)-____'}". Note must single quote