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 528

addError

public void addError (string $message)

Adds error message to the list.

Input
string $message error message
Output
void  

line 250

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 228

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 215

addTracker

public void addTracker ()

Output
void  
Tags
Deprecated

line 141

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 562

cleanErrors

public void cleanErrors ()

Output
void  

line 438

fireEvents

public void fireEvents ()

Fires submit/click events.

Output
void  

line 178

getAction

public mixed getAction ()

Returns form's action.

Output
mixed URI

line 578

getElementPrototype

public Html getElementPrototype ()

Returns form's HTML element template.

Output
Html  

line 339

getEncoding

public string getEncoding ()

Returns the encoding.

Output
string  

line 542

getErrors

public array getErrors ()

Returns validation errors.

Output
array  

line 154

getForm

public Form getForm ([$need = TRUE])

Returns self.

Input
$need
Output
Form  

line 312

getGroup

public FormGroup getGroup (string $name)

Returns the specified group.

Input
string $name name
Output
FormGroup  

line 300

getGroups

public array getGroups ()

Returns all defined groups.

Output
array of FormGroup

line 421

getHttpData

public array getHttpData ()

Returns submitted HTTP data.

Output
array  

line 663

getHttpRequest

protected IHttpRequest getHttpRequest ()

Output
IHttpRequest  

line 205

getMethod

public string getMethod ()

Returns form's method.

Output
string get | post

line 602

getRenderer

public IFormRenderer|NULL getRenderer ()

Returns form renderer.

Output
IFormRenderer|NULL  

line 673

getSession

protected Session getSession ()

Output
Session  

line 367

getTranslator

public ITranslator|NULL getTranslator ()

Returns translate adapter.

Output
ITranslator|NULL  

line 510

getValues

public array getValues ()

Returns the values submitted by the form.

Output
array  

line 552

hasErrors

public bool hasErrors ()

Output
bool  

line 382

isAnchored

public bool isAnchored ()

Tells if the form is anchored.

Overridden in child classes as:

Output
bool  

line 393

isSubmitted

public ISubmitterControl|FALSE isSubmitted ()

Tells if the form was submitted.

Output
ISubmitterControl|FALSE submittor control

line 494

processHttpRequest

public void processHttpRequest ()

Output
void  
Tags
Deprecated

line 466

receiveHttpData

protected array receiveHttpData ()

Internal: receives submitted HTTP data.

Overridden in child classes as:

Output
array  

line 274

removeGroup

public void removeGroup (string|FormGroup $name)

Removes fieldset group from form.

Input
string|FormGroup $name
Output
void  

line 616

render

public void render ()

Renders form.

Output
void  

line 166

setAction

public Form setAction (mixed $url)

Sets form's action.

Input
mixed $url URI
Output
Form provides a fluent interface

line 324

setEncoding

public Form setEncoding (string $value)

Set the encoding for the values.

Input
string $value
Output
Form provides a fluent interface

line 190

setMethod

public Form setMethod (string $method)

Sets form's method.

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

line 590

setRenderer

public Form setRenderer (IFormRenderer $renderer)

Sets form renderer.

Input
IFormRenderer $renderer
Output
Form provides a fluent interface

line 409

setSubmittedBy

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

Sets the submittor control.

Input
ISubmitterControl $by
Output
Form provides a fluent interface

line 355

setTranslator

public Form setTranslator ([$translator = NULL])

Sets translate adapter.

Input
$translator
Output
Form provides a fluent interface

line 636

__toString

public bool __toString ()

Renders form to string.

Output
bool can throw exceptions? (hidden parameter)