/functions/forms.php

Description

forms.php - html form functions

Functions to build HTML forms in a safe and consistent manner. All name, value attributes are htmlentitied.

Functions
addCheckBox (line 43)

Form checkbox

void addCheckBox ( $name, [ $checked = false], [ $value = null], [ $extra_attributes = ''])
  • $name
  • $checked
  • $value
  • $extra_attributes
addForm (line 154)

Make a <form> start-tag.

void addForm (string $action, [string $method = 'post'], [string $name = ''], [string $enctype = ''], [string $charset = ''], [string $extra = ''], [mixed $add_token = FALSE])
  • string $action
  • string $method
  • string $name
  • string $enctype
  • string $charset
  • string $extra: Any other attributes can be added with this parameter; they should use double quotes around attribute values (OPTIONAL; default empty)
  • mixed $add_token: When given as a string or as boolean TRUE, a hidden input is also added to the form containing a security token. When given as TRUE, the input name is "smtoken"; otherwise the name is the string that is given for this parameter. When FALSE, no hidden token input field is added. (OPTIONAL; default not used)
addHidden (line 59)

A hidden form field.

void addHidden ( $name,  $value)
  • $name
  • $value
addInput (line 66)

An input textbox.

void addInput ( $name, [ $value = ''], [ $size = 0], [ $maxlength = 0], [ $extra_attributes = ''])
  • $name
  • $value
  • $size
  • $maxlength
  • $extra_attributes
addInputField (line 24)

Helper function to create form fields, not to be called directly, only by other functions below.

void addInputField ( $type, [ $name = null], [ $value = null], [ $attributes = ''])
  • $type
  • $name
  • $value
  • $attributes
addPwField (line 35)

Password input field

void addPwField ( $name, [ $value = null], [ $extra_attributes = ''])
  • $name
  • $value
  • $extra_attributes
addRadioBox (line 51)

Form radio box

void addRadioBox ( $name, [ $checked = false], [ $value = null])
  • $name
  • $checked
  • $value
addReset (line 121)

Form reset button, $value = caption

void addReset ( $value)
  • $value
addSelect (line 87)

Function to create a selectlist from an array.

Usage: name: html name attribute values: array ( key => value ) -> <option value="key">value</option> default: the key that will be selected usekeys: use the keys of the array as option value or not

void addSelect ( $name,  $values, [ $default = null], [ $usekeys = false])
  • $name
  • $values
  • $default
  • $usekeys
addSubmit (line 115)

Form submission button

Note the switched value/name parameters!

void addSubmit ( $value, [ $name = null], [ $extra_attributes = ''])
  • $value
  • $name
  • $extra_attributes
addTextArea (line 128)

Textarea form element.

void addTextArea ( $name, [ $text = ''], [ $cols = 40], [ $rows = 10], [ $attr = ''])
  • $name
  • $text
  • $cols
  • $rows
  • $attr

Documentation generated on Thu, 23 Oct 2014 04:21:32 +0200 by phpDocumentor 1.4.3