Brimbox Logo Brimbox Version 2.3.4 Released

The Form Process Methods>>

In Brimbox, the $main object has several methods for the purpose of checking, posting, and initializing variables plus dealing with state, including retrieving and updating state values. They are contained in class bb_work (bb_work.php), along with several functions not discussed here;

These are the methods used in processing form data:

function button($number, $check)

  • checks to see if a particular button has been submitted, can also check where the submit is coming from using the $check parameter.

function name($name, $module)

  • Returns the string $name, usually a form variable, with module name prepended.

function blank(&$name)

  • Checks to see if a string is empty or blank, will set the variable if not set (or NULL).

function init(&$var, $default)

  • Initializes a variable with the specified default if not set. Does not prepend module name.

function hot($check)

  • Used when dealing with hot state, checks the $submit module is set and not postback ($module = $submit)

function back($module)

  • Checks whether the module is entered from a back button. True if module is entered from a back button $POST['bb_module'] <> $module. False if normal tab change or submit $POST['bb_module'] = $module.

function check($name, $module)

  • Returns boolean true if $POST variable is set, like isset() but prepends module name automatically.

function changed($name, $module, $arr_state, $default = "")

  • Checks whether a $POST and $arr_state variable are different. Will but true if they are different, false if they are the same.

function full($name, $module)

  • Returns boolean to check if $POST variable is full, like !empty excluding “0”. Returns false if empty. Prepends module name before check.

function post($name, $module, $default = "")

  • Gets the $POST value of a variable. Prepends module name before check, also initializes.

function state($name, $arr_state, $default = "")

  • Returns the state value of a variable from $arr_state variable, will initialize the variable if not set.

function set($name, &$arr_state, $value)

  • Sets the state value in $arr_state using name as key from a variable.

function process($name, $module, &$arr_state, $default = "")

  • Fully processes $POST variable maintaining state.
  • First initializes variable with default.
  • Second overwrites variable with state if state is set.
  • Third overwrites variable with $POST if $POST is set.

function render($name, $module, &$arr_state, $type, &$check, $default = "", $error = false)

  • Fully processes $POST variable maintaining state including validation.
  • First initializes variable with default.
  • Second overwrites variable with state if state is set.
  • Third overwrites variable with $POST if $POST is set.
  • Fourth validates variable according to $type, setting $check to false and formatting variable according to validation function if valid. Sets $check to true if not valid.
  • Note: $check = true means there was a validation error.

function load($con, $name, $module)

  • Gets and initializes $arr_state array from the state_table in the database based on module name.

function retrieve($con)

  • Retrieves $POST from the state_table.

function update($con, $module, $arr_state)

  • Updates the state_table with $arr_state for a given module.

function hot_state($con)

  • Updates the state of a module when going to a different module (ie switching tabs or modules) without postback. Will not work with back button.

Updated: 2017-07-30