tce_functions_form.php

tce_functions_form.php source file reference

Package: com\tecnick\tcexam\shared

Tags

  • file: Functions to handle XHTML Form Fields.
  • author: Nicola Asuni
  • since: 2001-11-07

Constants

K_EMAIL_RE_PATTERN

File: tce_functions_form.php line 53

public mixed K_EMAIL_RE_PATTERN = '^([a-zA-Z0-9_\.\-\+\%]+)@([a-zA-Z0-9\.\-]+)$'

Functions

F_decode_form_fields()

File: tce_functions_form.php line 59

F_decode_form_fields() : array<string|int, mixed>

Return values

array<string|int, mixed> —

containing form fields

F_check_required_fields()

File: tce_functions_form.php line 70

F_check_required_fields(mixed $formfields) : array<string|int, mixed>

Parameters

  • $formfields : mixed: (string) input array containing form fields

Return values

array<string|int, mixed> —

containing a list of missing fields (if any)

F_get_field_format_registry()

File: tce_functions_form.php line 116

F_get_field_format_registry() : array<string, string>

This is the single source of truth used by F_check_fields_format() to validate submitted values. The matching pattern is resolved here, on the server, by field name.

Field names are static across the application, so a flat “name => un-delimited regex” map is sufficient. Configurable constants are reused where they already exist.

Return values

array<string, string> —

map of field name to un-delimited regular expression

F_check_fields_format()

File: tce_functions_form.php line 162

F_check_fields_format(mixed $formfields) : string

For every field present in F_get_field_format_registry() that was submitted with a non-empty value, the value is matched against its canonical (server-authored) pattern. The client-supplied ‘x_’ value is ignored entirely, so a tampered/omitted/malicious pattern can neither bypass validation nor be executed as a regular expression.

Parameters

  • $formfields : mixed: (array) input array containing form fields

Return values

string —

comma-separated list of wrong fields (empty when all valid)

F_check_form_fields()

File: tce_functions_form.php line 212

F_check_form_fields() : false

see: F_check_required_fields, F_check_fields_format

Return values

false —

in case of error, true otherwise

F_close_button()

File: tce_functions_form.php line 239

F_close_button([mixed $onclick = '' ]) : XHTML

Parameters

  • $onclick : mixed = ‘’: (string) additional javascript code to execute before closing the window.

Return values

XHTML —

code string

F_submit_button()

File: tce_functions_form.php line 270

F_submit_button(mixed $name, mixed $value[, mixed $title = '' ][, mixed $extra = '' ]) : XHTML

Parameters

  • $name : mixed: (string) button name
  • $value : mixed: (string) label for button
  • $title : mixed = ‘’: (string) button title, default=’’
  • $extra : mixed = ‘’: (string) optional extra fields to add to the input tag, default=’’

Return values

XHTML —

code string

F_getCSRFTokenField()

File: tce_functions_form.php line 291

F_getCSRFTokenField() : XHTML

Return values

XHTML —

code string

getRequiredMark()

File: tce_functions_form.php line 302

getRequiredMark([mixed $required = false ]) : string

The control itself should also carry aria-required=“true”.

Parameters

  • $required : mixed = false: (boolean) true if the field is required.

Return values

string —

XHTML code (empty string when the field is not required).

getFormRowTextInput()

File: tce_functions_form.php line 334

getFormRowTextInput(mixed $field_name, mixed $name[, mixed $description = '' ][, mixed $tip = '' ][, mixed $value = '' ][, mixed $format = '' ][, mixed $maxlen = 255 ][, mixed $date = false ][, mixed $datetime = false ][, mixed $password = false ][, mixed $prefix = '' ][, mixed $required = false ][, mixed $autocomplete = '' ][, mixed $inputtype = '' ]) : string

Parameters

  • $field_name : mixed: (string) Name of the form field.
  • $name : mixed: (string) Label.
  • $description : mixed = ‘’: (string) Label description (tooltip).
  • $tip : mixed = ‘’: (string) Help to be displayed on the right of the input field.
  • $value : mixed = ‘’: (string) Initial value.
  • $format : mixed = ‘’: (string) Regular expression to check the format of the field.
  • $maxlen : mixed = 255: (int) Maximum input length.
  • $date : mixed = false: (boolean) True if the field is a date input.
  • $datetime : mixed = false: (boolean) True if the field is a date-time input.
  • $password : mixed = false: (boolean) True if the field is a password.
  • $prefix : mixed = ‘’: (string) code to be displayed after label.
  • $required : mixed = false: (boolean) If true the field is marked as required.
  • $autocomplete : mixed = ‘’: (string) HTML autocomplete token (e.g. ’email’, ‘username’, ‘current-password’, ’new-password’).
  • $inputtype : mixed = ‘’: (string) Override for the HTML input type (e.g. ’email’, ’tel’, ’number’); ignored for password/date/datetime fields.

Return values

string

getFormRowTextBox()

File: tce_functions_form.php line 481

getFormRowTextBox(mixed $field_name, mixed $name[, mixed $description = '' ][, mixed $value = '' ][, mixed $disabled = false ][, mixed $prefix = '' ][, mixed $required = false ]) : string

Parameters

  • $field_name : mixed: (string) Name of the form field.
  • $name : mixed: (string) Label.
  • $description : mixed = ‘’: (string) Label description (tooltip).
  • $value : mixed = ‘’: (string) Initial value.
  • $disabled : mixed = false: (boolean) If true disable the field.
  • $prefix : mixed = ‘’: (string) code to be displayed after label.
  • $required : mixed = false: (boolean) If true the field is marked as required.

Return values

string

getFormRowSelectBox()

File: tce_functions_form.php line 541

getFormRowSelectBox(mixed $field_name, mixed $name[, mixed $description = '' ][, mixed $tip = '' ][, mixed $value = '' ][, mixed $items = [] ][, mixed $prefix = '' ][, mixed $required = false ]) : string

Parameters

  • $field_name : mixed: (string) Name of the form field.
  • $name : mixed: (string) Label.
  • $description : mixed = ‘’: (string) Label description (tooltip).
  • $tip : mixed = ‘’: (string) Help to be displayed on the right of the input field.
  • $value : mixed = ‘’: (string) Initial value.
  • $items : mixed = []: (array) array of items to print key => value.
  • $prefix : mixed = ‘’: (string) code to be displayed after label.
  • $required : mixed = false

Return values

string

getFormRowCheckBox()

File: tce_functions_form.php line 616

getFormRowCheckBox(mixed $field_name, mixed $name[, mixed $description = '' ][, mixed $tip = '' ][, mixed $value = '' ][, mixed $selected = false ][, mixed $disabled = false ][, mixed $prefix = '' ]) : string

Parameters

  • $field_name : mixed: (string) Name of the form field.
  • $name : mixed: (string) Label.
  • $description : mixed = ‘’: (string) Label description (tooltip).
  • $tip : mixed = ‘’: (string) Help to be displayed on the right of the input field.
  • $value : mixed = ‘’: (string) Initial value.
  • $selected : mixed = false: (boolean) set to true if selected.
  • $disabled : mixed = false: (boolean) set to true to disable the field
  • $prefix : mixed = ‘’: (string) code to be displayed after label.

Return values

string

getFormRowFixedValue()

File: tce_functions_form.php line 693

getFormRowFixedValue(mixed $field_name, mixed $name[, mixed $description = '' ][, mixed $tip = '' ][, mixed $value = '' ][, mixed $currency = false ][, mixed $prefix = '' ]) : string

Parameters

  • $field_name : mixed: (string) Name of the form field.
  • $name : mixed: (string) Label.
  • $description : mixed = ‘’: (string) Label description (tooltip).
  • $tip : mixed = ‘’: (string) Help to be displayed on the right of the input field.
  • $value : mixed = ‘’: (string) Initial value.
  • $currency : mixed = false: (boolean) if true the value is a curency number.
  • $prefix : mixed = ‘’: (string) code to be displayed after label.

Return values

string

getFormSmallVertSpace()

File: tce_functions_form.php line 762

getFormSmallVertSpace() : string

Return values

string

getFormSmallDivSpace()

File: tce_functions_form.php line 771

getFormSmallDivSpace() : string

Return values

string

getFormRowVertSpace()

File: tce_functions_form.php line 780

getFormRowVertSpace() : string

Return values

string

getFormRowVertDiv()

File: tce_functions_form.php line 790

getFormRowVertDiv([mixed $title = '' ]) : string

Parameters

  • $title : mixed = ‘’: (string) Title to be printed.

Return values

string

getFormNoscriptSelect()

File: tce_functions_form.php line 805

getFormNoscriptSelect([mixed $name = 'selectrecord' ]) : string

Parameters

  • $name : mixed = ‘selectrecord’: (string) Name of the input form field.

Return values

string

getFormDescriptionLine()

File: tce_functions_form.php line 827

getFormDescriptionLine(mixed $name[, mixed $description = '' ][, mixed $value = '' ]) : string

Parameters

  • $name : mixed: (string) Label.
  • $description : mixed = ‘’: (string) Label description (tooltip).
  • $value : mixed = ‘’: (string) Initial value.

Return values

string

getFormUploadFile()

File: tce_functions_form.php line 852

getFormUploadFile(mixed $field_name, mixed $field_id, mixed $name[, mixed $description = '' ][, mixed $onchange = '' ]) : string

Parameters

  • $field_name : mixed: (string) Name of the form field.
  • $field_id : mixed: (string) ID of the form field.
  • $name : mixed: (string) Label.
  • $description : mixed = ‘’: (string) Label description (tooltip).
  • $onchange : mixed = ‘’: (string) Javascript code to execute at onchange event.

Return values

string