Source for file forms.php
Documentation is available at forms.php
* forms.php - html form functions
* Functions to build HTML forms in a safe and consistent manner.
* All name, value attributes are htmlentitied.
* @link http://www.section508.gov/ Section 508
* @link http://www.w3.org/WAI/ Web Accessibility Initiative (WAI)
* @link http://www.w3.org/TR/html4/ W3.org HTML 4.01 form specs
* @copyright 2004-2020 The SquirrelMail Project Team
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
* @version $Id: forms.php 14840 2020-01-07 07:42:38Z pdontthink $
* Helper function to create form fields, not to be called directly,
* only by other functions below.
function addInputField($type, $name =
null, $value =
null, $attributes =
'') {
return '<input type="'.
$type.
'"'.
' ' .
$attributes .
" />\n";
function addPwField($name , $value =
null, $extra_attributes=
'') {
return addInputField('password', $name , $value, $extra_attributes);
function addCheckBox($name, $checked =
false, $value =
null, $extra_attributes=
'') {
($checked ?
' checked="checked"' :
'') .
$extra_attributes);
function addRadioBox($name, $checked =
false, $value =
null) {
($checked ?
' checked="checked"' :
''));
function addInput($name, $value =
'', $size =
0, $maxlength =
0, $extra_attributes=
'') {
$extra_attributes .=
' size="'.(int)
$size.
'"';
$extra_attributes .=
' maxlength="'.(int)
$maxlength .
'"';
* Function to create a selectlist from an array.
* 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
function addSelect($name, $values, $default =
null, $usekeys =
false)
if(count($values) ==
1) {
foreach ($values as $k =>
$v) {
$ret .=
'<option value="' .
(($default ==
$k) ?
' selected="selected"' :
'') .
* Note the switched value/name parameters!
function addSubmit($value, $name =
null, $extra_attributes=
'') {
return addInputField('submit', $name, $value, $extra_attributes);
* Form reset button, $value = caption
function addTextArea($name, $text =
'', $cols =
40, $rows =
10, $attr =
'') {
'rows="'.(int)
$rows .
'" cols="'.(int)
$cols.
'" '.
* Make a <form> start-tag.
* @param string $extra Any other attributes can be added with this parameter;
* they should use double quotes around attribute values
* (OPTIONAL; default empty)
* @param 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)
function addForm($action, $method =
'post', $name =
'', $enctype =
'', $charset =
'', $extra =
'', $add_token =
FALSE)
$name =
' name="'.
$name.
'"';
$enctype =
' enctype="'.
$enctype.
'"';
$form_string =
'<form action="'.
$action .
'" method="'.
$method .
'"'.
$enctype .
$name .
$charset .
' ' .
$extra .
" >\n";
.
'" name="' .
(is_string($add_token) ?
$add_token :
'smtoken')
Documentation generated on Mon, 13 Jan 2020 04:24:38 +0100 by phpDocumentor 1.4.3