Form
extends KBase
in package
Form class
Tags
Table of Contents
- $ajax : bool
- Variable to indicate whether Ajax form is being used or not.
- $gform : bool
- Variable to indicate whether the form is being used with GForm or not.
- $javascript : array<string|int, mixed>
- JavaScript
- $cfg : object
- Config class instance.
- $request : Request
- Server request class instance.
- $attributes : array<string|int, mixed>
- Tag attributes
- $tag : string
- Tag name
- button() : static
- Create a button element.
- checkbox() : static
- Create an input element of type "checkbox".
- color() : static
- Create an input element of type "color".
- currency() : static
- Create an input element for handling currency values.
- date() : static
- Create an input element of type "date".
- datetime() : static
- Create an input element of type "datetime".
- email() : static
- Create an input element of type "email".
- file() : static
- Create an input element of type "file".
- get2Input() : array<string|int, mixed>
- Retrieve input values from query parameters and parsed body.
- hidden() : static
- Create an input element of type "hidden".
- integer() : static
- Create an input element of type "integer" that allows negative values.
- number() : static
- Create an input element of type "number".
- password() : static
- Create an input element of type "password".
- radio() : static
- Create an input element of type "radio".
- range() : static
- Create an input element of type "range".
- render() : string
- Function for generating form elements.
- reset() : static
- Creates a reset button element.
- select() : static
- Creates a select dropdown element.
- submit() : static
- Creates a submit button or input field.
- tel() : static
- Create an input element of type "tel".
- text() : static
- Create an input element of type "text".
- textarea() : static
- Create an input element of type "textarea".
- time() : static
- Create an input element of type "time".
- url() : static
- Create an input element of type "url".
- create() : string
- Creates an HTML element with the specified attributes and inner HTML.
Properties
$ajax
Variable to indicate whether Ajax form is being used or not.
public
bool
$ajax
= false
GAjax must be called if this is set to true.
$gform
Variable to indicate whether the form is being used with GForm or not.
public
bool
$gform
= true
GAjax must be called if this is set to true.
$javascript
JavaScript
public
array<string|int, mixed>
$javascript
$cfg
Config class instance.
protected
static object
$cfg
$request
Server request class instance.
protected
static Request
$request
$attributes
Tag attributes
private
array<string|int, mixed>
$attributes
$tag
Tag name
private
string
$tag
Methods
button()
Create a button element.
public
static button([array<string|int, mixed> $attributes = [] ]) : static
Parameters
- $attributes : array<string|int, mixed> = []
-
An array of attributes for the input field.
Tags
Return values
static —checkbox()
Create an input element of type "checkbox".
public
static checkbox([array<string|int, mixed> $attributes = [] ]) : static
Parameters
- $attributes : array<string|int, mixed> = []
-
An array of attributes for the input field.
Tags
Return values
static —color()
Create an input element of type "color".
public
static color([array<string|int, mixed> $attributes = [] ]) : static
Parameters
- $attributes : array<string|int, mixed> = []
-
An array of attributes for the input field.
Tags
Return values
static —currency()
Create an input element for handling currency values.
public
static currency([array<string|int, mixed> $attributes = [] ]) : static
Parameters
- $attributes : array<string|int, mixed> = []
-
An array of attributes for the input field.
Tags
Return values
static —date()
Create an input element of type "date".
public
static date([array<string|int, mixed> $attributes = [] ]) : static
Parameters
- $attributes : array<string|int, mixed> = []
-
An array of attributes for the input field.
Tags
Return values
static —datetime()
Create an input element of type "datetime".
public
static datetime([array<string|int, mixed> $attributes = [] ]) : static
Parameters
- $attributes : array<string|int, mixed> = []
-
An array of attributes for the input field.
Tags
Return values
static —email()
Create an input element of type "email".
public
static email([array<string|int, mixed> $attributes = [] ]) : static
Parameters
- $attributes : array<string|int, mixed> = []
-
An array of attributes for the input field.
Tags
Return values
static —file()
Create an input element of type "file".
public
static file([array<string|int, mixed> $attributes = [] ]) : static
Parameters
- $attributes : array<string|int, mixed> = []
-
An array of attributes for the input field.
Tags
Return values
static —get2Input()
Retrieve input values from query parameters and parsed body.
public
static get2Input() : array<string|int, mixed>
Return values
array<string|int, mixed> —An array of hidden input elements.
hidden()
Create an input element of type "hidden".
public
static hidden([array<string|int, mixed> $attributes = [] ]) : static
Parameters
- $attributes : array<string|int, mixed> = []
-
An array of attributes for the input field.
Tags
Return values
static —integer()
Create an input element of type "integer" that allows negative values.
public
static integer([array<string|int, mixed> $attributes = [] ]) : static
Parameters
- $attributes : array<string|int, mixed> = []
-
An array of attributes for the input field.
Tags
Return values
static —number()
Create an input element of type "number".
public
static number([array<string|int, mixed> $attributes = [] ]) : static
Parameters
- $attributes : array<string|int, mixed> = []
-
An array of attributes for the input field.
Tags
Return values
static —password()
Create an input element of type "password".
public
static password([array<string|int, mixed> $attributes = [] ]) : static
Parameters
- $attributes : array<string|int, mixed> = []
-
An array of attributes for the input field.
Tags
Return values
static —radio()
Create an input element of type "radio".
public
static radio([array<string|int, mixed> $attributes = [] ]) : static
Parameters
- $attributes : array<string|int, mixed> = []
-
An array of attributes for the input field.
Tags
Return values
static —range()
Create an input element of type "range".
public
static range([array<string|int, mixed> $attributes = [] ]) : static
Parameters
- $attributes : array<string|int, mixed> = []
-
An array of attributes for the input field.
Tags
Return values
static —render()
Function for generating form elements.
public
render() : string
The function supports the following parameters:
- id, name, type: properties of the input element.
- options: for select elements only, an array of options in the format array('value1' => 'name1', 'value2' => 'name2', ...).
- datalist: for text input elements, an array of options in the format array('value1' => 'name1', 'value2' => 'name2', ...).
- label: the label text to display for the input element.
- labelClass: the CSS class of the label.
- comment: if specified, displays a description of the input.
If neither label nor labelClass is specified, only the input element will be created.
Return values
string —The generated HTML for the form element.
reset()
Creates a reset button element.
public
static reset([array<string|int, mixed> $attributes = [] ]) : static
Parameters
- $attributes : array<string|int, mixed> = []
-
An array of attributes for the input field.
Tags
Return values
static —select()
Creates a select dropdown element.
public
static select([array<string|int, mixed> $attributes = [] ]) : static
Parameters
- $attributes : array<string|int, mixed> = []
-
An array of attributes for the input field.
Tags
Return values
static —submit()
Creates a submit button or input field.
public
static submit([array<string|int, mixed> $attributes = [] ]) : static
Parameters
- $attributes : array<string|int, mixed> = []
-
An array of attributes for the input field.
Tags
Return values
static —tel()
Create an input element of type "tel".
public
static tel([array<string|int, mixed> $attributes = [] ]) : static
Parameters
- $attributes : array<string|int, mixed> = []
-
An array of attributes for the input field.
Tags
Return values
static —text()
Create an input element of type "text".
public
static text([array<string|int, mixed> $attributes = [] ]) : static
Parameters
- $attributes : array<string|int, mixed> = []
-
An array of attributes for the input field.
Tags
Return values
static —textarea()
Create an input element of type "textarea".
public
static textarea([array<string|int, mixed> $attributes = [] ]) : static
Parameters
- $attributes : array<string|int, mixed> = []
-
An array of attributes for the input field.
Tags
Return values
static —time()
Create an input element of type "time".
public
static time([array<string|int, mixed> $attributes = [] ]) : static
Parameters
- $attributes : array<string|int, mixed> = []
-
An array of attributes for the input field.
Tags
Return values
static —url()
Create an input element of type "url".
public
static url([array<string|int, mixed> $attributes = [] ]) : static
Parameters
- $attributes : array<string|int, mixed> = []
-
An array of attributes for the input field.
Tags
Return values
static —create()
Creates an HTML element with the specified attributes and inner HTML.
private
static create(string $elem, string $id, string $class, string $innerHTML) : string
Parameters
- $elem : string
-
The HTML element tag name
- $id : string
-
The value of the 'id' attribute
- $class : string
-
The value of the 'class' attribute
- $innerHTML : string
-
The inner HTML content of the element
Return values
string —The generated HTML element