Namespaces

  • Nette
    • Application
    • Caching
    • Collections
    • Config
    • Forms
    • IO
    • Loaders
    • Mail
    • Reflection
    • Security
    • Templates
    • Web
  • None
  • PHP

Classes

  • Button
  • Checkbox
  • ConventionalRenderer
  • FileUpload
  • Form
  • FormContainer
  • FormControl
  • FormGroup
  • HiddenField
  • ImageButton
  • InstantClientScript
  • MultiSelectBox
  • RadioList
  • Rule
  • Rules
  • SelectBox
  • SubmitButton
  • TextArea
  • TextBase
  • TextInput

Interfaces

  • IFormControl
  • IFormRenderer
  • INamingContainer
  • ISubmitterControl
  • Overview
  • Namespace
  • Class
  • Tree
  • Other releases

Class Form

Creates, validates and renders HTML forms.

Nette\Object
Extended by Nette\Component implements Nette\IComponent
Extended by Nette\ComponentContainer implements Nette\IComponentContainer
Extended by Nette\Forms\FormContainer implements ArrayAccess, Nette\Forms\INamingContainer
Extended by Nette\Forms\Form

Direct known subclasses

Nette\Application\AppForm
Namespace: Nette\Forms
Author: David Grudl
Example: forms/basic-example.php Form definition using fluent interfaces
Example: forms/manual-rendering.php Manual form rendering and separated form and rules definition
Example: forms/localization.php Localization (with Zend_Translate)
Example: forms/custom-rendering.php Custom form rendering
Example: forms/custom-validator.php How to use custom validator
Example: forms/naming-containers.php How to use naming containers
Example: forms/CSRF-protection.php How to use Cross-Site Request Forgery (CSRF) form protection
Example: forms/custom-encoding.php How to change charset
Located at Forms/Form.php
Methods summary
public
# __construct( string $name = NULL )

Form constructor.

Form constructor.

Parameters

$name
string
protected
# 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.

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

Parameters

$obj
IComponent
final public Nette\Forms\Form
# getForm( boolean $need = TRUE )

Returns self.

Returns self.

Parameters

$need
boolean
throw exception if form doesn't exist?

Returns

Nette\Forms\Form
public Nette\Forms\Form
# setAction( mixed $url )

Sets form's action.

Sets form's action.

Parameters

$url
mixed
URI

Returns

Nette\Forms\Form
provides a fluent interface
public mixed
# getAction( )

Returns form's action.

Returns form's action.

Returns

mixed
URI
public Nette\Forms\Form
# setMethod( string $method )

Sets form's method.

Sets form's method.

Parameters

$method
string
get | post

Returns

Nette\Forms\Form
provides a fluent interface
public string
# getMethod( )

Returns form's method.

Returns form's method.

Returns

string
get | post
public
# addProtection( string $message = NULL, integer $timeout = NULL )

Cross-Site Request Forgery (CSRF) form protection.

Cross-Site Request Forgery (CSRF) form protection.

Parameters

$message
string
$timeout
integer
public Nette\Forms\FormGroup
# addGroup( string $caption = NULL, boolean $setAsCurrent = TRUE )

Adds fieldset group to the form.

Adds fieldset group to the form.

Parameters

$caption
string
caption
$setAsCurrent
boolean
set this group as current

Returns

Nette\Forms\FormGroup
public
# removeGroup( string|Nette\Forms\FormGroup $name )

Removes fieldset group from form.

Removes fieldset group from form.

Parameters

$name
string|Nette\Forms\FormGroup
public array
# getGroups( )

Returns all defined groups.

Returns all defined groups.

Returns

array
of FormGroup
public Nette\Forms\FormGroup
# getGroup( string $name )

Returns the specified group.

Returns the specified group.

Parameters

$name
string
name

Returns

Nette\Forms\FormGroup
public Nette\Forms\Form
# setEncoding( string $value )

Set the encoding for the values.

Set the encoding for the values.

Parameters

$value
string

Returns

Nette\Forms\Form
provides a fluent interface
final public string
# getEncoding( )

Returns the encoding.

Returns the encoding.

Returns

string
public Nette\Forms\Form
# setTranslator( Nette\ITranslator $translator = NULL )

Sets translate adapter.

Sets translate adapter.

Parameters

$translator
Nette\ITranslator

Returns

Nette\Forms\Form
provides a fluent interface
final public Nette\ITranslator|null
# getTranslator( )

Returns translate adapter.

Returns translate adapter.

Returns

Nette\ITranslator|null
public boolean
# isAnchored( )

Tells if the form is anchored.

Tells if the form is anchored.

Returns

boolean
final public Nette\Forms\ISubmitterControl|false
# isSubmitted( )

Tells if the form was submitted.

Tells if the form was submitted.

Returns

Nette\Forms\ISubmitterControl|false
submittor control
public Nette\Forms\Form
# setSubmittedBy( Nette\Forms\ISubmitterControl $by = NULL )

Sets the submittor control.

Sets the submittor control.

Parameters

$by
Nette\Forms\ISubmitterControl

Returns

Nette\Forms\Form
provides a fluent interface
final public array
# getHttpData( )

Returns submitted HTTP data.

Returns submitted HTTP data.

Returns

array
public
# fireEvents( )

Fires submit/click events.

Fires submit/click events.

protected array
# receiveHttpData( )

Internal: receives submitted HTTP data.

Internal: receives submitted HTTP data.

Returns

array
public array
# getValues( )

Returns the values submitted by the form.

Returns the values submitted by the form.

Returns

array
public
# addError( string $message )

Adds error message to the list.

Adds error message to the list.

Parameters

$message
string
error message
public array
# getErrors( )

Returns validation errors.

Returns validation errors.

Returns

array
public boolean
# hasErrors( )

Returns

boolean
public
# cleanErrors( )
public Nette\Web\Html
# getElementPrototype( )

Returns form's HTML element template.

Returns form's HTML element template.

Returns

Nette\Web\Html
public Nette\Forms\Form
# setRenderer( Nette\Forms\IFormRenderer $renderer )

Sets form renderer.

Sets form renderer.

Parameters

$renderer
Nette\Forms\IFormRenderer

Returns

Nette\Forms\Form
provides a fluent interface
final public Nette\Forms\IFormRenderer|null
# getRenderer( )

Returns form renderer.

Returns form renderer.

Returns

Nette\Forms\IFormRenderer|null
public
# render( )

Renders form.

Renders form.

public boolean
# __toString( )

Renders form to string.

Renders form to string.

Returns

boolean
can throw exceptions? (hidden parameter)
string
protected Nette\Web\IHttpRequest
# getHttpRequest( )

Returns

Nette\Web\IHttpRequest
protected Nette\Web\Session
# getSession( )

Returns

Nette\Web\Session
Methods inherited from Nette\Forms\FormContainer
__clone(), addButton(), addCheckbox(), addComponent(), addContainer(), addFile(), addHidden(), addImage(), addMultiSelect(), addPassword(), addRadioList(), addSelect(), addSubmit(), addText(), addTextArea(), getControls(), isValid(), offsetExists(), offsetGet(), offsetSet(), offsetUnset(), setCurrentGroup(), setDefaults(), setValues(), validate()
Methods inherited from Nette\ComponentContainer
createComponent(), getComponent(), getComponents(), removeComponent(), validateChildComponent()
Methods inherited from Nette\Component
__wakeup(), detached(), getName(), getParent(), lookup(), lookupPath(), monitor(), setParent(), unmonitor(), validateParent()
Methods inherited from Nette\Object
__call(), __callStatic(), __get(), __isset(), __set(), __unset(), extensionMethod(), getReflection()
Constants summary
string EQUAL ':equal'
#

operation name

operation name

string IS_IN ':equal'
#
string FILLED ':filled'
#
string VALID ':valid'
#
string SUBMITTED ':submitted'
#
string MIN_LENGTH ':minLength'
#
string MAX_LENGTH ':maxLength'
#
string LENGTH ':length'
#
string EMAIL ':email'
#
string URL ':url'
#
string REGEXP ':regexp'
#
string INTEGER ':integer'
#
string NUMERIC ':integer'
#
string FLOAT ':float'
#
string RANGE ':range'
#
string MAX_FILE_SIZE ':fileSize'
#
string MIME_TYPE ':mimeType'
#
string SCRIPT 'Nette\\Forms\\InstantClientScript::javascript'
#
string GET 'get'
#

method

method

string POST 'post'
#
string TRACKER_ID '_form_'
#
string PROTECTOR_ID '_token_'
#
Constants inherited from Nette\IComponent
NAME_SEPARATOR
Properties summary
public array $onSubmit
#

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

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

public array $onInvalidSubmit
#

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

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

Properties inherited from Nette\Forms\FormContainer
$currentGroup, $onValidate, $valid
Nette Framework 0.9.7 API documentation generated by ApiGen 2.3.0