Class NFormControl


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

NObject
   |
   --NComponent
      |
      --NFormControl

Implements interfaces:

Author: David Grudl
Copyright: Copyright (c) 2004, 2009 David Grudl
Abstract:
Located: in /Forms/Controls/FormControl.php (line 51)
Public Method Summary
NFormControl
__construct ([string $caption = NULL])
NRules
addCondition (mixed $operation, [mixed $value = NULL])
Adds a validation condition a returns new branch.
NRules
addConditionOn (IFormControl $control, mixed $operation, [mixed $value = NULL])
Adds a validation condition based on another control a returns new branch.
void
addError (string $message)
Adds error message to the list.
NFormControl
addRule (mixed $operation, [string $message = NULL], [mixed $arg = NULL])
Adds a validation rule.
void
NHtml
Generates control's HTML element.
NHtml
Returns control's HTML element template.
array
Returns errors corresponding to control.
NForm
getForm ([bool $need = TRUE])
Returns form.
string
Returns control's HTML id.
string
Returns name of control within a NForm & INamingContainer scope.
NHtml
getLabel ([string $caption = NULL])
Generates label's HTML element.
NHtml
Returns label's HTML element template.
mixed
getOption (string $key, [mixed $default = NULL])
Returns user-specific option.
array
Returns user-specific options.
NRules
ITranslator|NULL
Returns translate adapter.
mixed
Returns control's value.
bool
bool
Is control disabled?
bool
Does method getControl() have been called?
bool
Is control mandatory?
void
Loads HTTP data.
void
notifyRule (NRule $rule)
New rule or condition notification callback.
NFormControl
setDisabled ([bool $value = TRUE])
Disables or enables control.
NFormControl
setHtmlId (string $id)
Changes control's HTML id.
NFormControl
setOption (string $key, mixed $value)
Sets user-specific option.
NFormControl
setParent ([$parent = NULL], [string $name = NULL])
Overloaded parent setter. This method checks for invalid control name.
NFormControl
setRendered ([bool $value = TRUE])
Sets 'rendered' indicator.
NFormControl
setRequired ([string $message = NULL])
Makes control mandatory.
NFormControl
setTranslator ([$translator = NULL])
Sets translate adapter.
NFormControl
setValue (mixed $value)
Sets control's value.
string
translate (string $s)
Returns translated string.
static bool
validateEqual (IFormControl $control, mixed $arg)
Equal validator: are control's value and second parameter equal?
static bool
Filled validator: is control filled?
static bool
Valid validator: is control valid?
Protected Method Summary
protected void
attached (IComponent $form)
This method will be called when the component becomes attached to NForm.
Methods Inherited From NComponent
__construct(), attached(), detached(), getName(), getParent(), lookup(), lookupPath(), monitor(), setParent(), unmonitor(), validateParent(), __clone(), __wakeup()
Methods Inherited From NObject
extensionMethod(), getClass(), getReflection(), __call(), __callStatic(), __get(), __isset(), __set(), __unset()
Variable Summary
string $caption

line 57

textual caption or label
protected NHtml $control

line 63

control element template
static string $idMask 'frm%s-%s'

line 54

protected NHtml $label

line 66

label element template
protected mixed $value

line 60

unfiltered control value

Method Details

line 94

__construct

public NFormControl __construct ([string $caption = NULL])

Input
string $caption caption
Output
NFormControl  

line 474

addCondition

public NRules addCondition (mixed $operation, [mixed $value = NULL])

Adds a validation condition a returns new branch.

Input
mixed $operation condition type
mixed $value optional condition arguments
Output
NRules new branch

line 488

addConditionOn

public NRules addConditionOn (IFormControl $control, mixed $operation, [mixed $value = NULL])

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

Input
IFormControl $control form control
mixed $operation condition type
mixed $value optional condition arguments
Output
NRules new branch

line 600

addError

public void addError (string $message)

Adds error message to the list.

Input
string $message error message
Output
void  

line 460

addRule

public NFormControl addRule (mixed $operation, [string $message = NULL], [mixed $arg = NULL])

Adds a validation rule.

Input
mixed $operation rule type
string $message message to display for invalid data
mixed $arg optional rule arguments
Output
NFormControl provides a fluent interface

line 111

attached

protected void attached (IComponent $form)

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

Overridden in child classes as:

Input
IComponent $form
Output
void  

line 634

cleanErrors

public void cleanErrors ()

Output
void  

line 366

getControl

public NHtml getControl ()

Generates control's HTML element.

Output
NHtml  

line 405

getControlPrototype

public NHtml getControlPrototype ()

Returns control's HTML element template.

Output
NHtml  

line 614

getErrors

public array getErrors ()

Returns errors corresponding to control.

Implementation of:

Output
array  

line 141

getForm

public NForm getForm ([bool $need = TRUE])

Returns form.

Input
bool $need throw exception if form doesn't exist?
Output
NForm  

line 187

getHtmlId

public string getHtmlId ()

Returns control's HTML id.

Output
string  

line 152

getHtmlName

public string getHtmlName ()

Returns name of control within a NForm & INamingContainer scope.

Overridden in child classes as:

Output
string  

line 383

getLabel

public NHtml getLabel ([string $caption = NULL])

Generates label's HTML element.

Input
string $caption
Output
NHtml  

line 416

getLabelPrototype

public NHtml getLabelPrototype ()

Returns label's HTML element template.

Output
NHtml  

line 232

getOption

public mixed getOption (string $key, [mixed $default = NULL])

Returns user-specific option.

Input
string $key key
mixed $default default value
Output
mixed  

line 243

getOptions

public array getOptions ()

Returns user-specific options.

Output
array  

line 498

getRules

public NRules getRules ()

Implementation of:

Output
NRules  

line 271

getTranslator

public ITranslator|NULL getTranslator ()

Returns translate adapter.

Output
ITranslator|NULL  

line 315

getValue

public mixed getValue ()

Returns control's value.

Implementation of:

Output
mixed  

line 624

hasErrors

public bool hasErrors ()

Output
bool  

line 351

isDisabled

public bool isDisabled ()

Is control disabled?

Implementation of:

Output
bool  

line 442

isRendered

public bool isRendered ()

Does method getControl() have been called?

Output
bool  
Tags
Deprecated

line 524

isRequired

public bool isRequired ()

Is control mandatory?

Output
bool  
Tags
Deprecated

line 326

loadHttpData

public void loadHttpData ()

Loads HTTP data.

Overridden in child classes as:

Implementation of:

Output
void  

line 536

notifyRule

public void notifyRule (NRule $rule)

New rule or condition notification callback.

Overridden in child classes as:

Input
NRule $rule
Output
void  

line 339

setDisabled

public NFormControl setDisabled ([bool $value = TRUE])

Disables or enables control.

Input
bool $value
Output
NFormControl provides a fluent interface

line 175

setHtmlId

public NFormControl setHtmlId (string $id)

Changes control's HTML id.

Input
string $id new ID, or FALSE or NULL
Output
NFormControl provides a fluent interface

line 213

setOption

public NFormControl setOption (string $key, mixed $value)

Sets user-specific option.

Common options:

  • 'rendered' - indicate if method getControl() have been called
  • 'required' - indicate if ':required' rule has been applied
  • 'description' - textual or NHtml object description (recognized by NConventionalRenderer)

Input
string $key key
mixed $value value
Output
NFormControl provides a fluent interface

line 126

setParent

public NFormControl setParent ([$parent = NULL], [string $name = NULL])

Overloaded parent setter. This method checks for invalid control name.

Input
$parent
string $name
Output
NFormControl provides a fluent interface

line 429

setRendered

public NFormControl setRendered ([bool $value = TRUE])

Sets 'rendered' indicator.

Input
bool $value
Output
NFormControl provides a fluent interface
Tags
Deprecated

line 511

setRequired

public NFormControl setRequired ([string $message = NULL])

Makes control mandatory.

Input
string $message error message
Output
NFormControl provides a fluent interface
Tags
Deprecated

line 259

setTranslator

public NFormControl setTranslator ([$translator = NULL])

Sets translate adapter.

Input
$translator
Output
NFormControl provides a fluent interface

line 303

setValue

public NFormControl setValue (mixed $value)

Sets control's value.

Implementation of:

Input
mixed $value
Output
NFormControl provides a fluent interface

line 286

translate

public string translate (string $s)

Returns translated string.

Implementation of:

Input
string $s
Output
string  

line 555

validateEqual

public static bool validateEqual (IFormControl $control, mixed $arg)

Equal validator: are control's value and second parameter equal?

Input
IFormControl $control
mixed $arg
Output
bool  

line 576

validateFilled

public static bool validateFilled (IFormControl $control)

Filled validator: is control filled?

Input
IFormControl $control
Output
bool  

line 588

validateValid

public static bool validateValid (IFormControl $control)

Valid validator: is control valid?

Input
IFormControl $control
Output
bool