abstract class BaseControl extends Component implements Control

Base class that implements the basic functionality common to form controls.

Properties

static $idMask
mixed $value
Html read-only $control
Html read-only $label
bool $disabled
string|bool|null $htmlId
string|Stringable $caption
bool $omitted
bool $required
Form read-only $form
string read-only $htmlName
Html read-only $controlPrototype
Html read-only $labelPrototype
bool read-only $filled
array read-only $errors
array read-only $options
string read-only $error

Methods

__construct(string|Stringable|null $caption = null)

No description

setCaption(string|Stringable $caption)

Sets textual caption or label.

string|Stringable|null
getCaption()

No description

Form|null
getForm(bool $throw = true)

Returns form.

void
loadHttpData()

Loads HTTP data.

mixed
getHttpData($type, string|null $htmlTail = null)

Loads HTTP data.

string
getHtmlName()

Returns HTML name of control.

setValue(mixed $value)

Sets control's value.

mixed
getValue()

Returns control's value.

bool
isFilled()

Is control filled?

setDefaultValue($value)

Sets control's default value.

setDisabled(bool $value = true)

Disables or enables control.

bool
isDisabled()

Is control disabled?

setOmitted(bool $value = true)

Sets whether control value is excluded from $form->getValues() result.

bool
isOmitted()

Is control value excluded from $form->getValues() result?

Html|string
getControl()

Generates control's HTML element.

Html|string|null
getLabel(string|Stringable|null $caption = null)

Generates label's HTML element.

Html|null
getControlPart()

No description

Html|null
getLabelPart()

No description

getControlPrototype()

Returns control's HTML element template.

getLabelPrototype()

Returns label's HTML element template.

setHtmlId(string|bool|null $id)

Changes control's HTML id.

string|bool|null
getHtmlId()

Returns control's HTML id.

setHtmlAttribute(string $name, mixed $value = true)

Changes control's HTML attribute.

setAttribute(string $name, mixed $value = true) deprecated

No description

setTranslator(Translator|null $translator)

Sets translate adapter.

Translator|null
getTranslator()

Returns translate adapter.

mixed
translate($value, ...$parameters)

Returns translated string.

addRule(callable|string $validator, string|Stringable|null $errorMessage = null, mixed $arg = null)

Adds a validation rule.

addCondition($validator, $value = null)

Adds a validation condition a returns new branch.

addConditionOn(Control $control, $validator, $value = null)

Adds a validation condition based on another control a returns new branch.

addFilter(callable $filter)

Adds a input filter callback.

getRules()

No description

setRequired(string|Stringable|bool $value = true)

Makes control mandatory.

bool
isRequired()

Is control mandatory?

void
validate()

Performs the server side validation.

void
addError(string|Stringable $message, bool $translate = true)

Adds error message to the list.

string|null
getError()

Returns errors corresponding to control.

array
getErrors()

Returns errors corresponding to control.

bool
hasErrors()

No description

void
cleanErrors()

No description

setOption($key, mixed $value)

Sets user-specific option.

mixed
getOption($key, mixed $default = null)

Returns user-specific option.

array
getOptions()

Returns user-specific options.

mixed
__call(string $name, array $args)

No description

static void
extensionMethod(string $name, $callback)

No description

Details

at line 75
__construct(string|Stringable|null $caption = null)

No description

Parameters

string|Stringable|null $caption

at line 93
BaseControl setCaption(string|Stringable $caption)

Sets textual caption or label.

Parameters

string|Stringable $caption

Return Value

BaseControl

at line 100
string|Stringable|null getCaption()

No description

Return Value

string|Stringable|null

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

Returns form.

Parameters

bool $throw

Return Value

Form|null

at line 118
void loadHttpData()

Loads HTTP data.

Return Value

void

at line 127
protected mixed getHttpData($type, string|null $htmlTail = null)

Loads HTTP data.

Parameters

$type
string|null $htmlTail

Return Value

mixed

at line 136
string getHtmlName()

Returns HTML name of control.

Return Value

string

at line 149
Control setValue(mixed $value)

internal  
 

Sets control's value.

Parameters

mixed $value

Return Value

Control

at line 159
mixed getValue()

Returns control's value.

Return Value

mixed

at line 168
bool isFilled()

Is control filled?

Return Value

bool

at line 178
BaseControl setDefaultValue($value)

Sets control's default value.

Parameters

$value

Return Value

BaseControl

at line 192
BaseControl setDisabled(bool $value = true)

Disables or enables control.

Parameters

bool $value

Return Value

BaseControl

at line 207
bool isDisabled()

Is control disabled?

Return Value

bool

at line 216
BaseControl setOmitted(bool $value = true)

Sets whether control value is excluded from $form->getValues() result.

Parameters

bool $value

Return Value

BaseControl

at line 226
bool isOmitted()

Is control value excluded from $form->getValues() result?

Return Value

bool

at line 238
Html|string getControl()

Generates control's HTML element.

Return Value

Html|string

at line 255
Html|string|null getLabel(string|Stringable|null $caption = null)

Generates label's HTML element.

Parameters

string|Stringable|null $caption

Return Value

Html|string|null

at line 270
Html|null getControlPart()

No description

Return Value

Html|null

at line 276
Html|null getLabelPart()

No description

Return Value

Html|null

at line 285
Html getControlPrototype()

Returns control's HTML element template.

Return Value

Html

at line 294
Html getLabelPrototype()

Returns label's HTML element template.

Return Value

Html

at line 303
BaseControl setHtmlId(string|bool|null $id)

Changes control's HTML id.

Parameters

string|bool|null $id

Return Value

BaseControl

at line 313
string|bool|null getHtmlId()

Returns control's HTML id.

Return Value

string|bool|null

at line 330
BaseControl setHtmlAttribute(string $name, mixed $value = true)

Changes control's HTML attribute.

Parameters

string $name
mixed $value

Return Value

BaseControl

at line 350
BaseControl setAttribute(string $name, mixed $value = true) deprecated

deprecated use setHtmlAttribute()

No description

Parameters

string $name
mixed $value

Return Value

BaseControl

at line 362
BaseControl setTranslator(Translator|null $translator)

Sets translate adapter.

Parameters

Translator|null $translator

Return Value

BaseControl

at line 372
Translator|null getTranslator()

Returns translate adapter.

Return Value

Translator|null

at line 387
mixed translate($value, ...$parameters)

Returns translated string.

Parameters

$value
...$parameters

Return Value

mixed

at line 408
BaseControl addRule(callable|string $validator, string|Stringable|null $errorMessage = null, mixed $arg = null)

Adds a validation rule.

Parameters

callable|string $validator
string|Stringable|null $errorMessage
mixed $arg

Return Value

BaseControl

at line 421
Rules addCondition($validator, $value = null)

Adds a validation condition a returns new branch.

Parameters

$validator
$value

Return Value

Rules

at line 430
Rules addConditionOn(Control $control, $validator, $value = null)

Adds a validation condition based on another control a returns new branch.

Parameters

Control $control
$validator
$value

Return Value

Rules

at line 439
BaseControl addFilter(callable $filter)

Adds a input filter callback.

Parameters

callable $filter

Return Value

BaseControl

at line 446
Rules getRules()

No description

Return Value

Rules

at line 455
BaseControl setRequired(string|Stringable|bool $value = true)

Makes control mandatory.

Parameters

string|Stringable|bool $value

Return Value

BaseControl

at line 465
bool isRequired()

Is control mandatory?

Return Value

bool

at line 474
void validate()

Performs the server side validation.

Return Value

void

at line 488
void addError(string|Stringable $message, bool $translate = true)

Adds error message to the list.

Parameters

string|Stringable $message
bool $translate

Return Value

void

at line 497
string|null getError()

Returns errors corresponding to control.

Return Value

string|null

at line 506
array getErrors()

Returns errors corresponding to control.

Return Value

array

at line 512
bool hasErrors()

No description

Return Value

bool

at line 518
void cleanErrors()

No description

Return Value

void

at line 530
BaseControl setOption($key, mixed $value)

Sets user-specific option.

Parameters

$key
mixed $value

Return Value

BaseControl

at line 545
mixed getOption($key, mixed $default = null)

Returns user-specific option.

Parameters

$key
mixed $default

Return Value

mixed

at line 554
array getOptions()

Returns user-specific options.

Return Value

array

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

No description

Parameters

string $name
array $args

Return Value

mixed

Exceptions

MemberAccessException

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

No description

Parameters

string $name
$callback

Return Value

void