File/nasmail/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 69)

Creates form checkbox

  • return: html formated checkbox
string addCheckBox (string $name, [boolean $checked = false], [string $value = null], [array $aExtra = array()])
  • string $name: Field name
  • boolean $checked: checked/unchecked status
  • string $value: Field value
  • array $aExtra: (since 1.5) Extra attributes (must be properly sanitized)
addForm (line 244)

Creates a <form> start-tag.

  • return: html form tag
string addForm (string $action, [string $method = 'post'], [string $name = ''], [string $enctype = ''], [string $charset = ''])
  • string $action: Form action handler
  • string $method: Form method. post or get
  • string $name: Form name
  • string $enctype: 'application/x-www-form-urlencoded' or 'multipart/form-data'
  • string $charset: accept-charset value
addHidden (line 113)

Creates a hidden form field.

  • return: html formated hidden field
string addHidden (string $name, string $value)
  • string $name: Field name
  • string $value: Field value
addInput (line 127)

Creates an input textbox.

  • return: html formated input field
string addInput (string $name, [string $value = ''], [int $size = 0], [int $maxlength = 0], [array $aExtra = array()])
  • string $name: Field name
  • string $value: Field value
  • int $size: Field size
  • int $maxlength: Max number of chars
  • array $aExtra: (since 1.5) Extra attributes (must be properly sanitized)
addInputField (line 32)

Creates form field

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

  • return: html formated input field
string addInputField (string $type, [string $name = null], [string $value = null], [string $attributes = ''])
  • string $type: HTML input type. 'text', 'password', 'checkbox', 'radio', 'submit', 'reset', 'file', 'hidden', 'image', 'button'
  • string $name: Name of input field
  • string $value: Value of input field
  • string $attributes: additional field attributes
addPwField (line 47)

Creates password input field

  • return: html formated password field
string addPwField (string $name, [string $value = null], [array $aExtra = array()])
  • string $name: Field name
  • string $value: Field value
  • array $aExtra: (since 1.5) Extra attributes (must be properly sanitized)
addRadioBox (line 92)

Creates html form radio box

  • return: html formated radio box
string addRadioBox (string $name, [boolean $checked = false], [string $value = null], [array $aExtra = array()])
  • string $name: Field name
  • string $value: Field value
  • boolean $checked: selected/not selected status
  • array $aExtra: (since 1.5) Extra attributes (must be properly sanitized)
addReset (line 206)

Form reset button

string addReset (string $value, [array $aExtra = array()])
  • string $value: caption (Name of button)
  • array $aExtra: (since 1.5) Extra attributes (must be properly sanitized)
addSelect (line 157)

Create a select list from an array.

string addSelect (string $name, array $values, [string $default = null], [string $usekeys = false])
  • string $name: Field name
  • array $values: array ( key => value ) -> <option value="key">value</option>
  • string $default: selected key
  • string $usekeys: use the keys of the array as option value or not
addSubmit (line 187)

Form submission button

Note the switched value/name parameters!

  • return: html formated submit button
string addSubmit (string $value, [string $name = null], [array $aExtra = array()])
  • string $value: String displayed on button
  • string $name: Field name
  • array $aExtra: (since 1.5) Extra attributes (must be properly sanitized)
addTextArea (line 228)

Creates textarea form element.

  • return: html formated textarea
string addTextArea (string $name, [string $text = ''], [int $cols = 40], [int $rows = 10], [string $attr = ''])
  • string $name: Field name
  • string $text: Field value
  • int $cols: Number of chars per line
  • int $rows: Number of lines
  • string $attr: Additional attributes (must be sanitized)
nsm_form_check_token (line 280)

Checks form security token

  • since: 1.7
boolean nsm_form_check_token ([string $name = 'input_token'])
  • string $name: form key which stores token value
nsm_form_get_token (line 264)

Returns token which can be used to protect forms from cross site form attacks

  • since: 1.7
string nsm_form_get_token ()

Documentation generated on Sun, 22 Nov 2009 17:36:29 +0200 by phpDocumentor 1.4.3