Class FormControl (namespace Nette\Forms)


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

Object
   |
   --Component
      |
      --FormControl

Implements interfaces:

Copyright: Copyright (c) 2004, 2010 David Grudl
Abstract:
Located: in /Forms/Controls/FormControl.php (line 37)
Public Method Summary
FormControl
__construct ([string $caption = NULL])
Rules
addCondition (mixed $operation, [mixed $value = NULL])
Adds a validation condition a returns new branch.
Rules
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.
FormControl
addRule (mixed $operation, [string $message = NULL], [mixed $arg = NULL])
Adds a validation rule.
void
Html
Generates control's HTML element.
Html
Returns control's HTML element template.
array
Returns errors corresponding to control.
Form
getForm ([bool $need = TRUE])
Returns form.
string
Returns control's HTML id.
string
Returns name of control within a Form & INamingContainer scope.
Html
getLabel ([string $caption = NULL])
Generates label's HTML element.
Html
Returns label's HTML element template.
mixed
getOption (string $key, [mixed $default = NULL])
Returns user-specific option.
array
Returns user-specific options.
Rules
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 (Rule $rule)
New rule or condition notification callback.
FormControl
setDefaultValue (mixed $value)
Sets control's default value.
FormControl
setDisabled ([bool $value = TRUE])
Disables or enables control.
FormControl
setHtmlId (string $id)
Changes control's HTML id.
FormControl
setOption (string $key, mixed $value)
Sets user-specific option.
FormControl
setRendered ([bool $value = TRUE])
Sets 'rendered' indicator.
FormControl
setRequired ([string $message = NULL])
Makes control mandatory.
FormControl
setTranslator ([$translator = NULL])
Sets translate adapter.
FormControl
setValue (mixed $value)
Sets control's value.
string
translate (string $s, [int $count = NULL])
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 Form.
Methods Inherited From Component
__construct(), attached(), detached(), getName(), getParent(), lookup(), lookupPath(), monitor(), setParent(), unmonitor(), validateParent(), __clone(), __wakeup()
Methods Inherited From Object
extensionMethod(), getClass(), getReflection(), __call(), __callStatic(), __get(), __isset(), __set(), __unset()
Variable Summary
string $caption

line 43

textual caption or label
protected Html $control

line 49

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

line 40

protected Html $label

line 52

label element template
protected mixed $value

line 46

unfiltered control value

Method Details

line 80

__construct

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

Input
string $caption caption
Output
FormControl  

line 466

addCondition

public Rules 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
Rules new branch

line 480

addConditionOn

public Rules 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
Rules new branch

line 591

addError

public void addError (string $message)

Adds error message to the list.

Input
string $message error message
Output
void  

line 452

addRule

public FormControl 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
FormControl provides a fluent interface

line 97

attached

protected void attached (IComponent $form)

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

Overridden in child classes as:

Input
IComponent $form
Output
void  

line 625

cleanErrors

public void cleanErrors ()

Output
void  

line 358

getControl

public Html getControl ()

Generates control's HTML element.

Output
Html  

line 397

getControlPrototype

public Html getControlPrototype ()

Returns control's HTML element template.

Output
Html  

line 605

getErrors

public array getErrors ()

Returns errors corresponding to control.

Implementation of:

Output
array  

line 112

getForm

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

Returns form.

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

line 162

getHtmlId

public string getHtmlId ()

Returns control's HTML id.

Output
string  

line 123

getHtmlName

public string getHtmlName ()

Returns name of control within a Form & INamingContainer scope.

Output
string  

line 375

getLabel

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

Generates label's HTML element.

Input
string $caption
Output
Html  

line 408

getLabelPrototype

public Html getLabelPrototype ()

Returns label's HTML element template.

Output
Html  

line 207

getOption

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

Returns user-specific option.

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

line 218

getOptions

public array getOptions ()

Returns user-specific options.

Output
array  

line 490

getRules

public Rules getRules ()

Implementation of:

Output
Rules  

line 246

getTranslator

public ITranslator|NULL getTranslator ()

Returns translate adapter.

Output
ITranslator|NULL  

line 291

getValue

public mixed getValue ()

Returns control's value.

Implementation of:

Output
mixed  

line 615

hasErrors

public bool hasErrors ()

Output
bool  

line 343

isDisabled

public bool isDisabled ()

Is control disabled?

Implementation of:

Output
bool  

line 434

isRendered

public bool isRendered ()

Does method getControl() have been called?

Output
bool  
Tags
Deprecated

line 516

isRequired

public bool isRequired ()

Is control mandatory?

Output
bool  
Tags
Deprecated

line 318

loadHttpData

public void loadHttpData ()

Loads HTTP data.

Overridden in child classes as:

Implementation of:

Output
void  

line 528

notifyRule

public void notifyRule (Rule $rule)

New rule or condition notification callback.

Overridden in child classes as:

Input
Rule $rule
Output
void  

line 303

setDefaultValue

public FormControl setDefaultValue (mixed $value)

Sets control's default value.

Input
mixed $value
Output
FormControl provides a fluent interface

line 331

setDisabled

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

Disables or enables control.

Input
bool $value
Output
FormControl provides a fluent interface

line 150

setHtmlId

public FormControl setHtmlId (string $id)

Changes control's HTML id.

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

line 188

setOption

public FormControl 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 Html object description (recognized by ConventionalRenderer)

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

line 421

setRendered

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

Sets 'rendered' indicator.

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

line 503

setRequired

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

Makes control mandatory.

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

line 234

setTranslator

public FormControl setTranslator ([$translator = NULL])

Sets translate adapter.

Input
$translator
Output
FormControl provides a fluent interface

line 279

setValue

public FormControl setValue (mixed $value)

Sets control's value.

Implementation of:

Input
mixed $value
Output
FormControl provides a fluent interface

line 262

translate

public string translate (string $s, [int $count = NULL])

Returns translated string.

Implementation of:

Input
string $s
int $count plural count
Output
string  

line 547

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 567

validateFilled

public static bool validateFilled (IFormControl $control)

Filled validator: is control filled?

Input
IFormControl $control
Output
bool  

line 579

validateValid

public static bool validateValid (IFormControl $control)

Valid validator: is control valid?

Input
IFormControl $control
Output
bool