abstract class BaseControl extends Component implements IControl

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

Properties

static string $idMask
string $caption
mixed $value
Html read-only $control
Html read-only $label
bool $disabled
string $htmlId
ITranslator|null $translator
bool $omitted
bool $required
Form read-only $form
string read-only $htmlName
array read-only $options
bool read-only $filled
Html read-only $controlPrototype
Html read-only $labelPrototype
Rules read-only $rules
array read-only $errors
write-only $defaultValue

Methods

__construct($caption = NULL)

No description

void
attached($form)

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

getForm($need = TRUE)

Returns form.

void
loadHttpData()

Loads HTTP data.

mixed
getHttpData($type, $htmlTail = NULL)

Loads HTTP data.

string
getHtmlName()

Returns HTML name of control.

void
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
getControlPrototype()

Returns control's HTML element template.

Html
getLabelPrototype()

Returns label's HTML element template.

setHtmlId($id)

Changes control's HTML id.

string
getHtmlId()

Returns control's HTML id.

setAttribute($name, $value = TRUE)

Changes control's HTML attribute.

setTranslator(ITranslator $translator = NULL)

Sets translate adapter.

ITranslator|null
getTranslator()

Returns translate adapter.

string
translate($value, $count = NULL)

Returns translated string.

addRule($validator, $message = 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()

Performs the server side validation.

void
addError($message)

Adds error message to the list.

string
getError()

Returns errors corresponding to control.

array
getErrors()

Returns errors corresponding to control.

bool
hasErrors()

No description

void
cleanErrors()

No description

static array
exportRules($rules)

No description

static bool
validateEqual(IControl $control, $arg)

Is control's value equal with second parameter?

static bool
validateNotEqual(IControl $control, $arg)

Is control's value not equal with second parameter?

static bool
validateFilled(IControl $control)

Is control filled?

static bool
validateBlank(IControl $control)

Is control not filled?

static bool
validateValid(IControl $control)

Is control valid?

static bool
validateRange(IControl $control, $range)

Is a control's value number in specified range?

static bool
validateMin(IControl $control, $minimum)

Is a control's value number greater than or equal to the specified minimum?

static bool
validateMax(IControl $control, $maximum)

Is a control's value number less than or equal to the specified maximum?

static bool
validateLength(IControl $control, $range)

Count/length validator. Range is array, min and max length pair.

static bool
validateMinLength(IControl $control, $length)

Has control's value minimal count/length?

static bool
validateMaxLength(IControl $control, $length)

Is control's value count/length in limit?

setOption($key, $value)

Sets user-specific option.

mixed
getOption($key, $default = NULL)

Returns user-specific option.

array
getOptions()

Returns user-specific options.

Details

at line 79
__construct($caption = NULL)

No description

Parameters

$caption

at line 96
protected void attached($form)

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

Parameters

$form

Return Value

void

at line 109
Form getForm($need = TRUE)

Returns form.

Parameters

$need

Return Value

Form

at line 119
void loadHttpData()

Loads HTTP data.

Return Value

void

at line 129
mixed getHttpData($type, $htmlTail = NULL)

Loads HTTP data.

Parameters

$type
$htmlTail

Return Value

mixed

at line 139
string getHtmlName()

Returns HTML name of control.

Return Value

string

at line 152
void setValue($value)

Sets control's value.

Parameters

$value

Return Value

void

at line 163
mixed getValue()

Returns control's value.

Return Value

mixed

at line 173
bool isFilled()

Is control filled?

Return Value

bool

at line 184
BaseControl setDefaultValue($value)

Sets control's default value.

Parameters

$value

Return Value

BaseControl

at line 199
BaseControl setDisabled($value = TRUE)

Disables or enables control.

Parameters

$value

Return Value

BaseControl

at line 213
bool isDisabled()

Is control disabled?

Return Value

bool

at line 224
BaseControl setOmitted($value = TRUE)

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

Parameters

$value

Return Value

BaseControl

at line 235
bool isOmitted()

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

Return Value

bool

at line 248
Html|string getControl()

Generates control's HTML element.

Return Value

Html|string

at line 267
Html|string getLabel($caption = NULL)

Generates label's HTML element.

Parameters

$caption

Return Value

Html|string

at line 280
Html getControlPrototype()

Returns control's HTML element template.

Return Value

Html

at line 290
Html getLabelPrototype()

Returns label's HTML element template.

Return Value

Html

at line 301
BaseControl setHtmlId($id)

Changes control's HTML id.

Parameters

$id

Return Value

BaseControl

at line 312
string getHtmlId()

Returns control's HTML id.

Return Value

string

at line 327
BaseControl setAttribute($name, $value = TRUE)

Changes control's HTML attribute.

Parameters

$name
$value

Return Value

BaseControl

at line 341
BaseControl setTranslator(ITranslator $translator = NULL)

Sets translate adapter.

Parameters

ITranslator $translator

Return Value

BaseControl

at line 352
ITranslator|null getTranslator()

Returns translate adapter.

Return Value

ITranslator|null

at line 367
string translate($value, $count = NULL)

Returns translated string.

Parameters

$value
$count

Return Value

string

at line 391
BaseControl addRule($validator, $message = NULL, $arg = NULL)

Adds a validation rule.

Parameters

$validator
$message
$arg

Return Value

BaseControl

at line 404
Rules addCondition($validator, $value = NULL)

Adds a validation condition a returns new branch.

Parameters

$validator
$value

Return Value

Rules

new branch

at line 417
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 426
Rules getRules()

No description

Return Value

Rules

at line 437
BaseControl setRequired($value = TRUE)

Makes control mandatory.

Parameters

$value

Return Value

BaseControl

at line 448
bool isRequired()

Is control mandatory?

Return Value

bool

at line 458
void validate()

Performs the server side validation.

Return Value

void

at line 473
void addError($message)

Adds error message to the list.

Parameters

$message

Return Value

void

at line 483
string getError()

Returns errors corresponding to control.

Return Value

string

at line 493
array getErrors()

Returns errors corresponding to control.

Return Value

array

at line 502
bool hasErrors()

No description

Return Value

bool

at line 511
void cleanErrors()

No description

Return Value

void

at line 520
static protected array exportRules($rules)

No description

Parameters

$rules

Return Value

array

at line 565
static bool validateEqual(IControl $control, $arg)

internal  
 

Is control's value equal with second parameter?

Parameters

IControl $control
$arg

Return Value

bool

at line 585
static bool validateNotEqual(IControl $control, $arg)

internal  
 

Is control's value not equal with second parameter?

Parameters

IControl $control
$arg

Return Value

bool

at line 596
static bool validateFilled(IControl $control)

internal  
 

Is control filled?

Parameters

IControl $control

Return Value

bool

at line 607
static bool validateBlank(IControl $control)

internal  
 

Is control not filled?

Parameters

IControl $control

Return Value

bool

at line 618
static bool validateValid(IControl $control)

internal  
 

Is control valid?

Parameters

IControl $control

Return Value

bool

at line 629
static bool validateRange(IControl $control, $range)

internal  
 

Is a control's value number in specified range?

Parameters

IControl $control
$range

Return Value

bool

at line 640
static bool validateMin(IControl $control, $minimum)

internal  
 

Is a control's value number greater than or equal to the specified minimum?

Parameters

IControl $control
$minimum

Return Value

bool

at line 651
static bool validateMax(IControl $control, $maximum)

internal  
 

Is a control's value number less than or equal to the specified maximum?

Parameters

IControl $control
$maximum

Return Value

bool

at line 662
static bool validateLength(IControl $control, $range)

internal  
 

Count/length validator. Range is array, min and max length pair.

Parameters

IControl $control
$range

Return Value

bool

at line 677
static bool validateMinLength(IControl $control, $length)

internal  
 

Has control's value minimal count/length?

Parameters

IControl $control
$length

Return Value

bool

at line 688
static bool validateMaxLength(IControl $control, $length)

internal  
 

Is control's value count/length in limit?

Parameters

IControl $control
$length

Return Value

bool

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

Sets user-specific option.

Parameters

$key
$value

Return Value

BaseControl

at line 716
mixed getOption($key, $default = NULL)

Returns user-specific option.

Parameters

$key
$default

Return Value

mixed

at line 726
array getOptions()

Returns user-specific options.

Return Value

array