abstract class BaseControl extends Component implements IControl

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

Properties

static string $idMask
string|object $caption
mixed $value
Html read-only $control
Html read-only $label
bool $disabled
mixed $htmlId
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($caption = null)

No description

void
attached($form)

This method will be called when the component becomes attached to Form.

Form|null
getForm($throw = true)

Returns form.

void
loadHttpData()

Loads HTTP data.

mixed
getHttpData($type, $htmlTail = null)

Loads HTTP data.

string
getHtmlName()

Returns HTML name of control.

setValue($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($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($caption = null)

Generates label's HTML element.

Html|null
getControlPart()

No description

Html|null
getLabelPart()

No description

Html
getControlPrototype()

Returns control's HTML element template.

Html
getLabelPrototype()

Returns label's HTML element template.

setHtmlId($id)

Changes control's HTML id.

mixed
getHtmlId()

Returns control's HTML id.

setHtmlAttribute($name, $value = true)

Changes control's HTML attribute.

setAttribute($name, $value = true)

Alias for setHtmlAttribute()

setTranslator(ITranslator $translator = null)

Sets translate adapter.

ITranslator|null
getTranslator()

Returns translate adapter.

mixed
translate($value, $count = null)

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($value = true)

Makes control mandatory.

bool
isRequired()

Is control mandatory?

void
validate()

No description

void
addError($message, $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 
enableAutoOptionalMode()

Globally enables new required/optional behavior.

setOption($key, $value)

Sets user-specific option.

mixed
getOption($key, $default = null)

Returns user-specific option.

array
getOptions()

Returns user-specific options.

__call($name, $args)

No description

static 
extensionMethod($name, $callback = null)

No description

Details

at line 78
__construct($caption = null)

No description

Parameters

$caption

at line 98
protected void attached($form)

This method will be called when the component becomes attached to Form.

Parameters

$form

Return Value

void

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

Returns form.

Parameters

$throw

Return Value

Form|null

at line 121
void loadHttpData()

Loads HTTP data.

Return Value

void

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

Loads HTTP data.

Parameters

$type
$htmlTail

Return Value

mixed

at line 141
string getHtmlName()

Returns HTML name of control.

Return Value

string

at line 155
IControl setValue($value)

internal  
 

Sets control's value.

Parameters

$value

Return Value

IControl

at line 166
mixed getValue()

Returns control's value.

Return Value

mixed

at line 176
bool isFilled()

Is control filled?

Return Value

bool

at line 187
BaseControl setDefaultValue($value)

Sets control's default value.

Parameters

$value

Return Value

BaseControl

at line 202
BaseControl setDisabled($value = true)

Disables or enables control.

Parameters

$value

Return Value

BaseControl

at line 217
bool isDisabled()

Is control disabled?

Return Value

bool

at line 228
BaseControl setOmitted($value = true)

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

Parameters

$value

Return Value

BaseControl

at line 239
bool isOmitted()

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

Return Value

bool

at line 252
Html|string getControl()

Generates control's HTML element.

Return Value

Html|string

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

Generates label's HTML element.

Parameters

$caption

Return Value

Html|string

at line 283
Html|null getControlPart()

No description

Return Value

Html|null

at line 292
Html|null getLabelPart()

No description

Return Value

Html|null

at line 302
Html getControlPrototype()

Returns control's HTML element template.

Return Value

Html

at line 312
Html getLabelPrototype()

Returns label's HTML element template.

Return Value

Html

at line 323
BaseControl setHtmlId($id)

Changes control's HTML id.

Parameters

$id

Return Value

BaseControl

at line 334
mixed getHtmlId()

Returns control's HTML id.

Return Value

mixed

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

Changes control's HTML attribute.

Parameters

$name
$value

Return Value

BaseControl

at line 362
BaseControl setAttribute($name, $value = true)

Alias for setHtmlAttribute()

Parameters

$name
$value

Return Value

BaseControl

at line 376
BaseControl setTranslator(ITranslator $translator = null)

Sets translate adapter.

Parameters

ITranslator $translator

Return Value

BaseControl

at line 387
ITranslator|null getTranslator()

Returns translate adapter.

Return Value

ITranslator|null

at line 402
mixed translate($value, $count = null)

Returns translated string.

Parameters

$value
$count

Return Value

mixed

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

Adds a validation rule.

Parameters

$validator
$errorMessage
$arg

Return Value

BaseControl

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

Adds a validation condition a returns new branch.

Parameters

$validator
$value

Return Value

Rules

new branch

at line 452
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 461
Rules getRules()

No description

Return Value

Rules

at line 472
BaseControl setRequired($value = true)

Makes control mandatory.

Parameters

$value

Return Value

BaseControl

at line 483
bool isRequired()

Is control mandatory?

Return Value

bool

at line 493
void validate()

No description

Return Value

void

at line 508
void addError($message, $translate = true)

Adds error message to the list.

Parameters

$message
$translate

Return Value

void

at line 518
string|null getError()

Returns errors corresponding to control.

Return Value

string|null

at line 528
array getErrors()

Returns errors corresponding to control.

Return Value

array

at line 537
bool hasErrors()

No description

Return Value

bool

at line 546
void cleanErrors()

No description

Return Value

void

at line 556
static enableAutoOptionalMode()

Globally enables new required/optional behavior.

This method will be deprecated in next version.

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

Sets user-specific option.

Parameters

$key
$value

Return Value

BaseControl

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

Returns user-specific option.

Parameters

$key
$default

Return Value

mixed

at line 594
array getOptions()

Returns user-specific options.

Return Value

array

at line 603
__call($name, $args)

No description

Parameters

$name
$args

at line 612
static extensionMethod($name, $callback = null)

No description

Parameters

$name
$callback