abstract class BaseControl extends Component implements IControl

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

Properties

static string $idMask
mixed $value
protected Html $control
protected Html $label
bool $disabled
mixed $htmlId
string|object $caption
bool $omitted
bool $required

Methods

__construct(string|object $caption = null)

No description

setCaption(object|string $caption)

Sets textual caption or label.

object|string
getCaption()

No description

Form|null
getForm(bool $throw = true)

Returns form.

void
loadHttpData()

Loads HTTP data.

mixed
getHttpData($type, string $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($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
getLabel(string|object $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.

mixed
getHtmlId()

Returns control's HTML id.

setHtmlAttribute(string $name, $value = true)

Changes control's HTML attribute.

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

No description

setTranslator(ITranslator|null $translator)

Sets translate adapter.

ITranslator|null
getTranslator()

Returns translate adapter.

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

Returns translated string.

addRule($validator, $errorMessage = null, $arg = null)

Adds a validation rule.

addCondition($validator, $value = null)

Adds a validation condition a returns new branch.

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

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

getRules()

No description

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

Makes control mandatory.

bool
isRequired()

Is control mandatory?

void
validate()

Performs the server side validation.

void
addError($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

static void
enableAutoOptionalMode() deprecated

No description

setOption($key, $value)

Sets user-specific option.

mixed
getOption($key, $default = null)

Returns user-specific option.

array
getOptions()

Returns user-specific options.

__call(string $name, array $args)

No description

static void
extensionMethod(string $name, $callback)

No description

Details

at line 81
__construct(string|object $caption = null)

Parameters

string|object $caption

at line 101
BaseControl setCaption(object|string $caption)

Sets textual caption or label.

Parameters

object|string $caption

Return Value

BaseControl

at line 111
object|string getCaption()

Return Value

object|string

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

Returns form.

Parameters

bool $throw

Return Value

Form|null

at line 129
void loadHttpData()

Loads HTTP data.

Return Value

void

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

Loads HTTP data.

Parameters

$type
string $htmlTail

Return Value

mixed

at line 148
string getHtmlName()

Returns HTML name of control.

Return Value

string

at line 162
IControl setValue(mixed $value)

Sets control's value.

Parameters

mixed $value

Return Value

IControl

at line 173
mixed getValue()

Returns control's value.

Return Value

mixed

at line 182
bool isFilled()

Is control filled?

Return Value

bool

at line 193
BaseControl setDefaultValue($value)

Sets control's default value.

Parameters

$value

Return Value

BaseControl

at line 207
BaseControl setDisabled($value = true)

Disables or enables control.

Parameters

$value

Return Value

BaseControl

at line 221
bool isDisabled()

Is control disabled?

Return Value

bool

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

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

Parameters

bool $value

Return Value

BaseControl

at line 241
bool isOmitted()

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

Return Value

bool

at line 254
Html|string getControl()

Generates control's HTML element.

Return Value

Html|string

at line 273
Html|string getLabel(string|object $caption = null)

Generates label's HTML element.

Parameters

string|object $caption

Return Value

Html|string

at line 284
Html|null getControlPart()

Return Value

Html|null

at line 290
Html|null getLabelPart()

Return Value

Html|null

at line 299
Html getControlPrototype()

Returns control's HTML element template.

Return Value

Html

at line 308
Html getLabelPrototype()

Returns label's HTML element template.

Return Value

Html

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

Changes control's HTML id.

Parameters

string|bool|null $id

Return Value

BaseControl

at line 330
mixed getHtmlId()

Returns control's HTML id.

Return Value

mixed

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

Changes control's HTML attribute.

Parameters

string $name
$value

Return Value

BaseControl

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

deprecated use setHtmlAttribute()

Parameters

string $name
$value

Return Value

BaseControl

at line 371
BaseControl setTranslator(ITranslator|null $translator)

Sets translate adapter.

Parameters

ITranslator|null $translator

Return Value

BaseControl

at line 381
ITranslator|null getTranslator()

Returns translate adapter.

Return Value

ITranslator|null

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

Returns translated string.

Parameters

$value
...$parameters

Return Value

mixed

at line 417
BaseControl addRule($validator, $errorMessage = null, $arg = null)

Adds a validation rule.

Parameters

$validator
$errorMessage
$arg

Return Value

BaseControl

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

Adds a validation condition a returns new branch.

Parameters

$validator
$value

Return Value

Rules new branch

at line 438
Rules addConditionOn(IControl $control, $validator, $value = null)

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

Parameters

IControl $control
$validator
$value

Return Value

Rules new branch

at line 444
Rules getRules()

Return Value

Rules

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

Makes control mandatory.

Parameters

bool|string|object $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($message, bool $translate = true)

Adds error message to the list.

Parameters

$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()

Return Value

bool

at line 518
void cleanErrors()

Return Value

void

at line 527
static void enableAutoOptionalMode() deprecated

deprecated

Return Value

void

at line 540
BaseControl setOption($key, $value)

Sets user-specific option.

Parameters

$key
$value

Return Value

BaseControl

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

Returns user-specific option.

Parameters

$key
$default

Return Value

mixed

at line 564
array getOptions()

Returns user-specific options.

Return Value

array

at line 573
__call(string $name, array $args)

Parameters

string $name
array $args

Exceptions

MemberAccessException

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

Parameters

string $name
$callback

Return Value

void