Class Form (namespace Nette\Forms)


Creates, validates and renders HTML forms.

Direct Known Sub-classes:

Public Method Summary
Form
__construct ([string $name = NULL])
Form constructor.
void
addError (string $message)
Adds error message to the list.
FormGroup
addGroup ([string $caption = NULL], [bool $setAsCurrent = TRUE])
Adds fieldset group to the form.
void
addProtection ([string $message = NULL], [int $timeout = NULL])
Cross-Site Request Forgery (CSRF) form protection.
void
void
void
Fires submit/click events.
mixed
Returns form's action.
Html
Returns form's HTML element template.
string
Returns the encoding.
array
Returns validation errors.
Form
getForm ([$need = TRUE])
Returns self.
FormGroup
getGroup (string $name)
Returns the specified group.
array
Returns all defined groups.
array
Returns submitted HTTP data.
string
Returns form's method.
IFormRenderer|NULL
Returns form renderer.
ITranslator|NULL
Returns translate adapter.
array
Returns the values submitted by the form.
bool
bool
Tells if the form is anchored.
ISubmitterControl|FALSE
Tells if the form was submitted.
void
void
removeGroup (string|FormGroup $name)
Removes fieldset group from form.
void
render ()
Renders form.
Form
setAction (mixed $url)
Sets form's action.
Form
setEncoding (string $value)
Set the encoding for the values.
Form
setMethod (string $method)
Sets form's method.
Form
setRenderer (IFormRenderer $renderer)
Sets form renderer.
Form
Sets the submittor control.
Form
setTranslator ([$translator = NULL])
Sets translate adapter.
bool
Renders form to string.
Protected Method Summary
protected void
This method will be called when the component (or component's parent) becomes attached to a monitored object. Do not call this method yourself.
protected IHttpRequest
protected Session
protected array
Internal: receives submitted HTTP data.
Methods Inherited From FormContainer
addButton(), addCheckbox(), addComponent(), addContainer(), addFile(), addHidden(), addImage(), addMultiSelect(), addPassword(), addRadioList(), addSelect(), addSubmit(), addText(), addTextArea(), getControls(), getForm(), getValues(), isValid(), offsetExists(), offsetGet(), offsetSet(), offsetUnset(), setCurrentGroup(), setDefaults(), setValues(), validate(), __clone()
Methods Inherited From ComponentContainer
addComponent(), createComponent(), getComponent(), getComponents(), removeComponent(), validateChildComponent(), __clone()
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()
Constant Summary
string EMAIL ':email'

line 56

operation name
string EQUAL ':equal'

line 44

operation name
string FILLED ':filled'

line 46

operation name
string FLOAT ':float'

line 61

operation name
string GET 'get'

line 73

method
string INTEGER ':integer'

line 59

operation name
string IS_IN ':equal'

line 45

operation name
string LENGTH ':length'

line 55

operation name
string MAX_FILE_SIZE ':fileSize'

line 65

operation name
string MAX_LENGTH ':maxLength'

line 54

operation name
string MIME_TYPE ':mimeType'

line 66

operation name
string MIN_LENGTH ':minLength'

line 53

operation name
string NUMERIC ':integer'

line 60

operation name
string POST 'post'

line 74

method
string RANGE ':range'

line 62

operation name
string REGEXP ':regexp'

line 58

operation name
string SCRIPT 'Nette\Forms\InstantClientScript::javascript'

line 69

operation name
string SUBMITTED ':submitted'

line 50

operation name
string URL ':url'

line 57

operation name
string VALID ':valid'

line 47

operation name
Variable Summary
array $onInvalidSubmit

line 87

of function(Form $sender); Occurs when the form is submitted and not validated
array $onSubmit

line 84

of function(Form $sender); Occurs when the form is submitted and successfully validated

Method Details

line 119

__construct

public Form __construct ([string $name = NULL])

Form constructor.

Overridden in child classes as:

Input
string $name
Output
Form  

line 530

addError

public void addError (string $message)

Adds error message to the list.

Input
string $message error message
Output
void  

line 252

addGroup

public FormGroup addGroup ([string $caption = NULL], [bool $setAsCurrent = TRUE])

Adds fieldset group to the form.

Input
string $caption caption
bool $setAsCurrent set this group as current
Output
FormGroup  

line 230

addProtection

public void addProtection ([string $message = NULL], [int $timeout = NULL])

Cross-Site Request Forgery (CSRF) form protection.

Input
string $message
int $timeout
Output
void  

line 217

addTracker

public void addTracker ()

Output
void  
Tags
Deprecated

line 143

attached

protected void attached (IComponent $obj)

This method will be called when the component (or component's parent) becomes attached to a monitored object. Do not call this method yourself.

Overridden in child classes as:

Input
IComponent $obj
Output
void  

line 564

cleanErrors

public void cleanErrors ()

Output
void  

line 440

fireEvents

public void fireEvents ()

Fires submit/click events.

Output
void  

line 180

getAction

public mixed getAction ()

Returns form's action.

Output
mixed URI

line 580

getElementPrototype

public Html getElementPrototype ()

Returns form's HTML element template.

Output
Html  

line 341

getEncoding

public string getEncoding ()

Returns the encoding.

Output
string  

line 544

getErrors

public array getErrors ()

Returns validation errors.

Output
array  

line 156

getForm

public Form getForm ([$need = TRUE])

Returns self.

Input
$need
Output
Form  

line 314

getGroup

public FormGroup getGroup (string $name)

Returns the specified group.

Input
string $name name
Output
FormGroup  

line 302

getGroups

public array getGroups ()

Returns all defined groups.

Output
array of FormGroup

line 423

getHttpData

public array getHttpData ()

Returns submitted HTTP data.

Output
array  

line 665

getHttpRequest

protected IHttpRequest getHttpRequest ()

Output
IHttpRequest  

line 207

getMethod

public string getMethod ()

Returns form's method.

Output
string get | post

line 604

getRenderer

public IFormRenderer|NULL getRenderer ()

Returns form renderer.

Output
IFormRenderer|NULL  

line 675

getSession

protected Session getSession ()

Output
Session  

line 369

getTranslator

public ITranslator|NULL getTranslator ()

Returns translate adapter.

Output
ITranslator|NULL  

line 512

getValues

public array getValues ()

Returns the values submitted by the form.

Output
array  

line 554

hasErrors

public bool hasErrors ()

Output
bool  

line 384

isAnchored

public bool isAnchored ()

Tells if the form is anchored.

Overridden in child classes as:

Output
bool  

line 395

isSubmitted

public ISubmitterControl|FALSE isSubmitted ()

Tells if the form was submitted.

Output
ISubmitterControl|FALSE submittor control

line 496

processHttpRequest

public void processHttpRequest ()

Output
void  
Tags
Deprecated

line 468

receiveHttpData

protected array receiveHttpData ()

Internal: receives submitted HTTP data.

Overridden in child classes as:

Output
array  

line 276

removeGroup

public void removeGroup (string|FormGroup $name)

Removes fieldset group from form.

Input
string|FormGroup $name
Output
void  

line 618

render

public void render ()

Renders form.

Output
void  

line 168

setAction

public Form setAction (mixed $url)

Sets form's action.

Input
mixed $url URI
Output
Form provides a fluent interface

line 326

setEncoding

public Form setEncoding (string $value)

Set the encoding for the values.

Input
string $value
Output
Form provides a fluent interface

line 192

setMethod

public Form setMethod (string $method)

Sets form's method.

Input
string $method get | post
Output
Form provides a fluent interface

line 592

setRenderer

public Form setRenderer (IFormRenderer $renderer)

Sets form renderer.

Input
IFormRenderer $renderer
Output
Form provides a fluent interface

line 411

setSubmittedBy

public Form setSubmittedBy ([ISubmitterControl $by = NULL])

Sets the submittor control.

Input
ISubmitterControl $by
Output
Form provides a fluent interface

line 357

setTranslator

public Form setTranslator ([$translator = NULL])

Sets translate adapter.

Input
$translator
Output
Form provides a fluent interface

line 638

__toString

public bool __toString ()

Renders form to string.

Output
bool can throw exceptions? (hidden parameter)