class Container extends Container implements ArrayAccess

Container for form controls.

Constants

Array

Properties

$onValidate

Occurs when the form was validated

protected $currentGroup
ArrayHash<mixed> $values
Iterator read-only $controls
Form read-only $form

Methods

setDefaults(iterable|stdClass $values, bool $erase = false)

Populates controls with default values. Has no effect on submitted forms.

setValues(iterable|stdClass $values, bool $erase = false, bool $onlyDisabled = false)

Fills controls with values.

object|array
getValues(string|object|null $returnType = null, array|null $controls = null)

Returns the values submitted by the form.

object|array
getUntrustedValues(string|object|null $returnType = null, array|null $controls = null)

Returns the potentially unvalidated values submitted by the form.

object|array
getUnsafeValues(string|object|null $returnType, array|null $controls = null) deprecated

No description

setMappedType(string $type)

Sets the default class used when getValues() is called without an explicit type.

bool
isValid()

Checks whether all controls pass validation.

void
validate(array|null $controls = null)

Performs the server side validation.

array
getErrors()

Returns all validation errors.

setCurrentGroup(ControlGroup|null $group = null)

Sets the group that newly added controls will be assigned to.

ControlGroup|null
getCurrentGroup()

No description

addComponent(IComponent $component, string|null $name, string|null $insertBefore = null)

Adds a component and assigns it to the current group if one is set.

iterable
getControls()

Retrieves the entire hierarchy of form controls including nested.

Form|null
getForm(bool $throw = true)

Returns form.

addText(string $name, string|Stringable|null $label = null, int|null $cols = null, int|null $maxLength = null)

Adds single-line text input control to the form.

addPassword(string $name, string|Stringable|null $label = null, int|null $cols = null, int|null $maxLength = null)

Adds single-line text input control used for sensitive input such as passwords.

addTextArea(string $name, string|Stringable|null $label = null, int|null $cols = null, int|null $rows = null)

Adds multi-line text input control to the form.

addEmail(string $name, string|Stringable|null $label = null, int $maxLength = 255)

Adds a text input with built-in email validation.

addInteger(string $name, string|Stringable|null $label = null)

Adds a text input with built-in integer validation.

addFloat(string $name, string|Stringable|null $label = null)

Adds a numeric input with built-in float validation.

addDate(string $name, string|Stringable|null $label = null)

Adds input for date selection.

addTime(string $name, string|Stringable|null $label = null, bool $withSeconds = false)

Adds input for time selection.

addDateTime(string $name, string|Stringable|null $label = null, bool $withSeconds = false)

Adds input for date and time selection.

addUpload(string $name, string|Stringable|null $label = null)

Adds control that allows the user to upload files.

addMultiUpload(string $name, string|Stringable|null $label = null)

Adds control that allows the user to upload multiple files.

addHidden(string $name, mixed $default = null)

Adds hidden form control used to store a non-displayed value.

addCheckbox(string $name, string|Stringable|null $caption = null)

Adds check box control to the form.

addRadioList(string $name, string|Stringable|null $label = null, array|null $items = null)

Adds set of radio button controls to the form.

addCheckboxList(string $name, string|Stringable|null $label = null, array|null $items = null)

Adds set of checkbox controls to the form.

addSelect(string $name, string|Stringable|null $label = null, array|null $items = null, int|null $size = null)

Adds select box control that allows single item selection.

addMultiSelect(string $name, string|Stringable|null $label = null, array|null $items = null, int|null $size = null)

Adds select box control that allows multiple item selection.

addColor(string $name, string|Stringable|null $label = null)

Adds an HTML color picker returning a hex color string (e.g. '#336699').

addSubmit(string $name, string|Stringable|null $caption = null, Closure|null $onSubmit = null)

Adds button used to submit form.

addButton(string $name, string|Stringable|null $caption = null)

Adds push buttons with no default behavior.

addImageButton(string $name, string|null $src = null, string|null $alt = null)

Adds graphical button used to submit form.

addImage()

No description

addContainer(string|int $name)

Adds a named sub-container for grouping related controls.

mixed
__call(string $name, array $args)

No description

static void
extensionMethod(string $name, callable $callback)

No description

__clone()

Prevents cloning.

Details

at line 51
Container setDefaults(iterable|stdClass $values, bool $erase = false)

Populates controls with default values. Has no effect on submitted forms.

Parameters

iterable|stdClass $values
bool $erase

Return Value

Container

at line 64
Container setValues(iterable|stdClass $values, bool $erase = false, bool $onlyDisabled = false)

internal  
 

Fills controls with values.

Parameters

iterable|stdClass $values
bool $erase
bool $onlyDisabled

Return Value

Container

at line 93
object|array getValues(string|object|null $returnType = null, array|null $controls = null)

Returns the values submitted by the form.

Parameters

string|object|null $returnType
array|null $controls

Return Value

object|array

at line 129
object|array getUntrustedValues(string|object|null $returnType = null, array|null $controls = null)

Returns the potentially unvalidated values submitted by the form.

Parameters

string|object|null $returnType
array|null $controls

Return Value

object|array

at line 184
object|array getUnsafeValues(string|object|null $returnType, array|null $controls = null) deprecated

deprecated use getUntrustedValues()

No description

Parameters

string|object|null $returnType
array|null $controls

Return Value

object|array

at line 196
Container setMappedType(string $type)

Sets the default class used when getValues() is called without an explicit type.

Parameters

string $type

Return Value

Container

at line 209
bool isValid()

Checks whether all controls pass validation.

Return Value

bool

at line 230
void validate(array|null $controls = null)

Performs the server side validation.

Parameters

array|null $controls

Return Value

void

at line 256
array getErrors()

Returns all validation errors.

Return Value

array

at line 273
Container setCurrentGroup(ControlGroup|null $group = null)

Sets the group that newly added controls will be assigned to.

Parameters

ControlGroup|null $group

Return Value

Container

at line 280
ControlGroup|null getCurrentGroup()

No description

Return Value

ControlGroup|null

at line 290
Container addComponent(IComponent $component, string|null $name, string|null $insertBefore = null)

Adds a component and assigns it to the current group if one is set.

Parameters

IComponent $component
string|null $name
string|null $insertBefore

Return Value

Container

Exceptions

InvalidStateException

at line 313
iterable getControls()

Retrieves the entire hierarchy of form controls including nested.

Return Value

iterable

at line 323
Form|null getForm(bool $throw = true)

Returns form.

Parameters

bool $throw

Return Value

Form|null

at line 335
TextInput addText(string $name, string|Stringable|null $label = null, int|null $cols = null, int|null $maxLength = null)

Adds single-line text input control to the form.

Parameters

string $name
string|Stringable|null $label
int|null $cols
int|null $maxLength

Return Value

TextInput

at line 350
TextInput addPassword(string $name, string|Stringable|null $label = null, int|null $cols = null, int|null $maxLength = null)

Adds single-line text input control used for sensitive input such as passwords.

Parameters

string $name
string|Stringable|null $label
int|null $cols
int|null $maxLength

Return Value

TextInput

at line 366
TextArea addTextArea(string $name, string|Stringable|null $label = null, int|null $cols = null, int|null $rows = null)

Adds multi-line text input control to the form.

Parameters

string $name
string|Stringable|null $label
int|null $cols
int|null $rows

Return Value

TextArea

at line 381
TextInput addEmail(string $name, string|Stringable|null $label = null, int $maxLength = 255)

Adds a text input with built-in email validation.

Parameters

string $name
string|Stringable|null $label
int $maxLength

Return Value

TextInput

at line 395
TextInput addInteger(string $name, string|Stringable|null $label = null)

Adds a text input with built-in integer validation.

Parameters

string $name
string|Stringable|null $label

Return Value

TextInput

at line 406
TextInput addFloat(string $name, string|Stringable|null $label = null)

Adds a numeric input with built-in float validation.

Parameters

string $name
string|Stringable|null $label

Return Value

TextInput

at line 419
DateTimeControl addDate(string $name, string|Stringable|null $label = null)

Adds input for date selection.

Parameters

string $name
string|Stringable|null $label

Return Value

DateTimeControl

at line 428
DateTimeControl addTime(string $name, string|Stringable|null $label = null, bool $withSeconds = false)

Adds input for time selection.

Parameters

string $name
string|Stringable|null $label
bool $withSeconds

Return Value

DateTimeControl

at line 441
DateTimeControl addDateTime(string $name, string|Stringable|null $label = null, bool $withSeconds = false)

Adds input for date and time selection.

Parameters

string $name
string|Stringable|null $label
bool $withSeconds

Return Value

DateTimeControl

at line 454
UploadControl addUpload(string $name, string|Stringable|null $label = null)

Adds control that allows the user to upload files.

Parameters

string $name
string|Stringable|null $label

Return Value

UploadControl

at line 463
UploadControl addMultiUpload(string $name, string|Stringable|null $label = null)

Adds control that allows the user to upload multiple files.

Parameters

string $name
string|Stringable|null $label

Return Value

UploadControl

at line 472
HiddenField addHidden(string $name, mixed $default = null)

Adds hidden form control used to store a non-displayed value.

Parameters

string $name
mixed $default

Return Value

HiddenField

at line 482
Checkbox addCheckbox(string $name, string|Stringable|null $caption = null)

Adds check box control to the form.

Parameters

string $name
string|Stringable|null $caption

Return Value

Checkbox

at line 492
RadioList addRadioList(string $name, string|Stringable|null $label = null, array|null $items = null)

Adds set of radio button controls to the form.

Parameters

string $name
string|Stringable|null $label
array|null $items

Return Value

RadioList

at line 506
CheckboxList addCheckboxList(string $name, string|Stringable|null $label = null, array|null $items = null)

Adds set of checkbox controls to the form.

Parameters

string $name
string|Stringable|null $label
array|null $items

Return Value

CheckboxList

at line 520
SelectBox addSelect(string $name, string|Stringable|null $label = null, array|null $items = null, int|null $size = null)

Adds select box control that allows single item selection.

Parameters

string $name
string|Stringable|null $label
array|null $items
int|null $size

Return Value

SelectBox

at line 536
MultiSelectBox addMultiSelect(string $name, string|Stringable|null $label = null, array|null $items = null, int|null $size = null)

Adds select box control that allows multiple item selection.

Parameters

string $name
string|Stringable|null $label
array|null $items
int|null $size

Return Value

MultiSelectBox

at line 551
ColorPicker addColor(string $name, string|Stringable|null $label = null)

Adds an HTML color picker returning a hex color string (e.g. '#336699').

Parameters

string $name
string|Stringable|null $label

Return Value

ColorPicker

at line 561
SubmitButton addSubmit(string $name, string|Stringable|null $caption = null, Closure|null $onSubmit = null)

Adds button used to submit form.

Parameters

string $name
string|Stringable|null $caption
Closure|null $onSubmit

Return Value

SubmitButton

at line 578
Button addButton(string $name, string|Stringable|null $caption = null)

Adds push buttons with no default behavior.

Parameters

string $name
string|Stringable|null $caption

Return Value

Button

at line 589
ImageButton addImageButton(string $name, string|null $src = null, string|null $alt = null)

Adds graphical button used to submit form.

Parameters

string $name
string|null $src

URI of the image

string|null $alt

alternate text for the image

Return Value

ImageButton

at line 595
ImageButton addImage()

No description

Return Value

ImageButton

at line 606
Container addContainer(string|int $name)

Adds a named sub-container for grouping related controls.

Parameters

string|int $name

Return Value

Container

at line 619
mixed __call(string $name, array $args)

No description

Parameters

string $name
array $args

Return Value

mixed

at line 630
static void extensionMethod(string $name, callable $callback)

No description

Parameters

string $name
callable $callback

Return Value

void

at line 643
__clone()

Prevents cloning.

Traits

SmartObject
ArrayAccess