CWIS Developer Documentation

- Home
- Main Page
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
FormUI Class Reference

Child class (covering presentation elements only) supplying a standard user interface for presenting and working with HTML forms. More...

Inheritance diagram for FormUI:
[legend]
Collaboration diagram for FormUI:
[legend]

## Public Member Functions
| DisplayFormTable ($TableId=NULL, $TableStyle=NULL, $TableCssClass=NULL)
| Display HTML table for form. More...
| HandleDeletes ()
| Handle image deletion, removing deleted images from text fields where they may have been inserted. More...
Public Member Functions inherited from FormUI_Base
| __construct ($FieldParams, $FieldValues=array(), $UniqueKey=NULL)
| Class constructor. More...
| DisplayFormTable ($TableId=NULL, $TableStyle=NULL)
| Display HTML table with settings parameters. More...
| ValidateFieldInput ()
| Validate field values on submitted form. More...
| AddValidationParameters ()
| Add values to be passed to input validation functions, in addition to field name and value. More...
| GetNewValuesFromForm ()
| Retrieve values set by form. More...
| GetFieldValue ($FieldName)
| Get value for form field. More...
| HandleUploads ()
| Handle image and file uploads. More...
| HandleDeletes ()
| Handle image and file deletions. More...
| SetEventToSignalOnChange ($EventName, $EventParams=array())
| Set event to signal when retrieving values from form when settings have changed. More...
| ValidateEmail ($FieldName, $FieldValues)
| Validate value as valid-appearing email address. More...
| ValidateUrl ($FieldName, $FieldValues)
| Validate value as valid-appearing URL. More...
| ValidateHostName ($FieldName, $FieldValues)
| Validate value as valid host name (i.e. More...

## Static Public Member Functions
static | DisplayErrorBlock ()
| Display HTML block with error messages (if any). More...
Static Public Member Functions inherited from FormUI_Base
static | LogError ($Msg, $Field=NULL)
| Log error message for later display. More...
static | GetLoggedErrors ()
| Get logged errors. More...
static | ErrorsLogged ($Field=FALSE)
| Report whether errors have been logged. More...
static | ClearLoggedErrors ($Field=FALSE)
| Clear logged errors. More...
static | DidValueChange ($OldValue, $NewValue)
| Determine if a new form field value is different from an old one. More...
static | LoadValue ($Type, $Data)
| Load value of requested type from supplied data. More...

## Public Attributes
const | OPTION_RADIO_BUTTON_THRESHOLD = 2
| FTYPE_OPTION fields with this many or fewer options will display as radio buttons by default. More...
Public Attributes inherited from FormUI_Base
const | FTYPE_FILE = "File"
| Supported field types. More...
const | FTYPE_FLAG = "Flag"
const | FTYPE_IMAGE = "Image"
const | FTYPE_METADATAFIELD = "MetadataField"
const | FTYPE_NUMBER = "Number"
const | FTYPE_OPTION = "Option"
const | FTYPE_PARAGRAPH = "Paragraph"
const | FTYPE_PASSWORD = "Password"
const | FTYPE_PRIVILEGES = "Privileges"
const | FTYPE_SEARCHPARAMS = "Search Parameters"
const | FTYPE_TEXT = "Text"
const | FTYPE_URL = "URL"
const | FTYPE_USER = "User"
const | FTYPE_QUICKSEARCH = "Quick Search"
const | FTYPE_HEADING = "Heading"
| Supported field pseudo-types. More...
const | NO_VALUE_FOR_FIELD = "NO VALUE"
| Marker used to indicate currently no value for field. More...

## Protected Member Functions
| DisplayFormField ($Name, $Value, $Params)
| Display HTML form field for specified field. More...
| DisplayImageField ($FieldName, $Value, $Params)
| Display image form field for specified field. More...
| DisplayFileField ($FieldName, $Value, $Params)
| Display file form field for specified field. More...
| PrintFieldHidingJavascript ()
| Print any JavaScript required to support toggling display of fields or sections. More...
Protected Member Functions inherited from FormUI_Base
| DisplayFormField ($Name, $Value, $Params)
| Display HTML form field for specified field. More...
| GetFormFieldName ($FieldName, $IncludePrefix=TRUE)
| Get HTML form field name for specified field. More...
| GetHiddenFieldsHtml ()
| Get HTML for hidden form fields associated with form processing. More...
| ConvertItemIdsToNames ($MField, $ItemIds)
| Take an array of ItemIds and convert it to [ ItemId => ItemName ]. More...

## Protected Attributes
| $UsingWysiwygEditor = FALSE
Protected Attributes inherited from FormUI_Base
| $DeletedFiles = array()
| $DeletedImages = array()
| $ExtraValidationParams = array()
| $ExtraValues = array()
| $FieldParams
| $FieldValues
| $HiddenFields = array()
| $SettingChangeEventName = NULL
| $SettingChangeEventParams = array()

## Additional Inherited Members
Static Protected Attributes inherited from FormUI_Base
static | $ErrorMessages = array()

## Detailed Description

Child class (covering presentation elements only) supplying a standard user interface for presenting and working with HTML forms.

NOTE: If any fields of type FTYPE_PRIVILEGE are included in the form, the enclosing <form> must have the class "priv-form" to work correctly. (This is a requirement of the PrivilegeEditingUI class.)

USAGE EXAMPLE

This implements a form for editing widget attributes, which are encapsulated within a "Widget" class, including photographs of widgets. The photos are displayed in a separate form section, below the other attributes. If the variable $DoNotEditName evaluates to TRUE, the name attribute of the widget will be displayed but not be editable. The same validation function can be used for multiple form fields by checking the value of $FieldName inside the function to decide how to validate the incoming value(s).

function MyValidateFunc($FieldName, $FieldValues, $AllFieldValues, $WidgetId)
{
if ($ValueLooksOkay)
{
return NULL;
}
else
{
return "An informative message about why the value(s) were invalid.";
}
}
$FormFields = array(
"WidgetName" => array(
"Type" => FormUI::FTYPE_TEXT,
"Label" => "Widget Name",
"Placeholder" => "(name of widget goes here)",
"Help" => "Name to use for widget.",
"ValidateFunction" => "MyValidateFunc",
"Required" => TRUE,
),
"WidgetDescription" => array(
"Type" => FormUI::FTYPE_PARAGRAPH,
"Label" => "Description",
"UseWYSIWYG" => TRUE,
"Help" => "Lurid description of widget.",
),
"WidgetType" => array(
"Type" => FormUI::FTYPE_OPTION,
"Label" => "Type of Widget",
"Help" => "The type of widget.",
"Options" => array(
WidgetClass::WT_NONE => "--",
WidgetClass::WT_FIRST => "First Type",
WidgetClass::WT_SECOND => "Second Type",
),
),
"WidgetCount" => array(
"Type" => FormUI::FTYPE_NUMBER,
"Label" => "Number of Widgets",
"MinVal" => 1,
"MaxVal" => 100,
"Required" => TRUE,
"Value" => $Widget->Count(),
),
"PhotoSectionHeader" => array(
"Type" => FormUI::FTYPE_HEADING,
"Label" => "Other Widget Info",
),
"WidgetPhotos" => array(
"Type" => FormUI::FTYPE_IMAGE,
"Label" => "Widget Images",
"Help" => "Photos of widgets.",
"AllowMultiple" => TRUE,
"InsertIntoField" => "WidgetDescription",
"MaxWidth" => 1000,
"MaxHeight" => 1000,
"MaxPreviewWidth" => 100,
"MaxPreviewHeight" => 100,
"MaxThumbnailWidth" => 50,
"MaxThumbnailHeight" => 50,
),
);
if ($DoNotEditName)
{
$FormFields["WidgetName"]["ReadOnly"] = TRUE;
}
$FormValues = array(
"WidgetName" => $Widget->Name(),
"WidgetDescription" => $Widget->Description(),
"WidgetType" => $Widget->Type(),
"WidgetPhotos" => array_keys(
$Widget->PhotosWithIdsForArrayIndex());
);
$H_FormUI = new FormUI($FormFields, $FormValues);
$H_FormUI->AddValidationParameters($Widget->Id());
switch ($ButtonPushed)
{
case "Save":
if ($H_FormUI->ValidateFieldInput() == 0)
{
$NewValues = $H_FormUI->GetNewValuesFromForm();
$Widget->Name($NewValues["WidgetName"]);
$Widget->Description($NewValues["WidgetDescription"]);
$Widget->Count($NewValues["WidgetCount"]);
$GLOBALS["AF"]->SetJumpToPage("BackToWhereverWhenDone");
}
break;
case "Upload":
$H_FormUI->HandleUploads();
break;
case "Delete":
$H_FormUI->HandleDeletes();
break;
}
FormUI::DisplayErrorBlock();
(start form)
$H_FormUI->DisplayFormTable();
(add submit buttons)
(end form)

Definition at line 134 of file FormUI.php.

## Member Function Documentation

static FormUI::DisplayErrorBlock | ( |  | ) |
| static

Display HTML block with error messages (if any).

Definition at line 294 of file FormUI.php.

FormUI::DisplayFileField | ( |  | $FieldName,
|  |  | $Value,
|  |  | $Params
| ) |  |
| protected

Display file form field for specified field.

Parameters

  string | $FieldName | Field name.
  mixed | $Value | Current value for field.
  array | $Params | Field parameters.

Definition at line 767 of file FormUI.php.

References FormUI_Base\$DeletedFiles, FormUI_Base\GetFormFieldName(), and PHP.

Referenced by DisplayFormField().

Here is the caller graph for this function:

FormUI::DisplayFormField | ( |  | $Name,
|  |  | $Value,
|  |  | $Params
| ) |  |
| protected

Display HTML form field for specified field.

Parameters

  string | $Name | Field name.
  mixed | $Value | Current value for field.
  array | $Params | Field parameters.

Definition at line 398 of file FormUI.php.

References DisplayFileField(), DisplayImageField(), FormUI_Base\GetFormFieldName(), MetadataSchema\MDFTYPE_REFERENCE, PHP, QuickSearchHelper\PrintQuickSearchField(), and MetadataSchema\SCHEMAID_DEFAULT.

Referenced by DisplayFormTable().

Here is the caller graph for this function:

FormUI::DisplayFormTable | ( |  | $TableId = `NULL`,
|  |  | $TableStyle = `NULL`,
|  |  | $TableCssClass = `NULL`
| ) |  |

Display HTML table for form.

Parameters

  string | $TableId | CSS ID for table element. (OPTIONAL)
  string | $TableStyle | CSS styles for table element. (OPTIONAL)
  string | $TableCssClass | Additional CSS class for table element. (OPTIONAL)

Definition at line 145 of file FormUI.php.

References DisplayFormField(), FormUI_Base\GetFieldValue(), FormUI_Base\GetFormFieldName(), FormUI_Base\GetHiddenFieldsHtml(), PHP, PrintFieldHidingJavascript(), and MetadataSchema\SCHEMAID_DEFAULT.

Referenced by ConfigSettingsUI\DisplaySettingsTable().

Here is the caller graph for this function:

FormUI::DisplayImageField | ( |  | $FieldName,
|  |  | $Value,
|  |  | $Params
| ) |  |
| protected

Display image form field for specified field.

Parameters

  string | $FieldName | Field name.
  mixed | $Value | Current value for field.
  array | $Params | Field parameters.

Definition at line 645 of file FormUI.php.

References FormUI_Base\$DeletedImages, FormUI_Base\GetFormFieldName(), and PHP.

Referenced by DisplayFormField().

Here is the caller graph for this function:

FormUI::HandleDeletes | ( |  | ) |

Handle image deletion, removing deleted images from text fields where they may have been inserted.

Definition at line 319 of file FormUI.php.

References FormUI_Base\GetFieldValue(), and FormUI_Base\GetFormFieldName().

FormUI::PrintFieldHidingJavascript | ( |  | ) |
| protected

Print any JavaScript required to support toggling display of fields or sections.

Definition at line 862 of file FormUI.php.

References FormUI_Base\GetFormFieldName(), and PHP.

Referenced by DisplayFormTable().

Here is the caller graph for this function:

## Member Data Documentation

FormUI::$UsingWysiwygEditor = FALSE
| protected

Definition at line 384 of file FormUI.php.

const FormUI::OPTION_RADIO_BUTTON_THRESHOLD = 2

FTYPE_OPTION fields with this many or fewer options will display as radio buttons by default.

Definition at line 390 of file FormUI.php.

The documentation for this class was generated from the following file:

- interface/default/objects/FormUI.php