Packages

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

Classes

  • NButton
  • NCheckbox
  • NConventionalRenderer
  • NFileUpload
  • NForm
  • NFormContainer
  • NFormGroup
  • NHiddenField
  • NImageButton
  • NInstantClientScript
  • NMultiSelectBox
  • NRadioList
  • NRule
  • NRules
  • NSelectBox
  • NSubmitButton
  • NTextArea
  • NTextBase
  • NTextInput

Interfaces

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

Class NForm

Creates, validates and renders HTML forms.

NObject
Extended by NComponent implements IComponent
Extended by NComponentContainer implements IComponentContainer
Extended by NFormContainer implements ArrayAccess, INamingContainer
Extended by NForm

Direct known subclasses

NAppForm
Package: 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 NForm
# getForm( boolean $need = TRUE )

Returns self.

Returns self.

Parameters

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

Returns

NForm
public NForm
# setAction( mixed $url )

Sets form's action.

Sets form's action.

Parameters

$url
mixed
URI

Returns

NForm
provides a fluent interface
public mixed
# getAction( )

Returns form's action.

Returns form's action.

Returns

mixed
URI
public NForm
# setMethod( string $method )

Sets form's method.

Sets form's method.

Parameters

$method
string
get | post

Returns

NForm
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 NFormGroup
# 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

NFormGroup
public
# removeGroup( string|FormGroup $name )

Removes fieldset group from form.

Removes fieldset group from form.

Parameters

$name
string|FormGroup
public array
# getGroups( )

Returns all defined groups.

Returns all defined groups.

Returns

array
of FormGroup
public NFormGroup
# getGroup( string $name )

Returns the specified group.

Returns the specified group.

Parameters

$name
string
name

Returns

NFormGroup
public NForm
# setEncoding( string $value )

Set the encoding for the values.

Set the encoding for the values.

Parameters

$value
string

Returns

NForm
provides a fluent interface
final public string
# getEncoding( )

Returns the encoding.

Returns the encoding.

Returns

string
public NForm
# setTranslator( ITranslator $translator = NULL )

Sets translate adapter.

Sets translate adapter.

Parameters

$translator
ITranslator

Returns

NForm
provides a fluent interface
final public ITranslator|null
# getTranslator( )

Returns translate adapter.

Returns translate adapter.

Returns

ITranslator|null
public boolean
# isAnchored( )

Tells if the form is anchored.

Tells if the form is anchored.

Returns

boolean
final public ISubmitterControl|false
# isSubmitted( )

Tells if the form was submitted.

Tells if the form was submitted.

Returns

ISubmitterControl|false
submittor control
public NForm
# setSubmittedBy( ISubmitterControl $by = NULL )

Sets the submittor control.

Sets the submittor control.

Parameters

$by
ISubmitterControl

Returns

NForm
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 NHtml
# getElementPrototype( )

Returns form's HTML element template.

Returns form's HTML element template.

Returns

NHtml
public NForm
# setRenderer( IFormRenderer $renderer )

Sets form renderer.

Sets form renderer.

Parameters

$renderer
IFormRenderer

Returns

NForm
provides a fluent interface
final public IFormRenderer|null
# getRenderer( )

Returns form renderer.

Returns form renderer.

Returns

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 IHttpRequest
# getHttpRequest( )

Returns

IHttpRequest
protected NSession
# getSession( )

Returns

NSession
Methods inherited from NFormContainer
__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 NComponentContainer
createComponent(), getComponent(), getComponents(), removeComponent(), validateChildComponent()
Methods inherited from NComponent
__wakeup(), detached(), getName(), getParent(), lookup(), lookupPath(), monitor(), setParent(), unmonitor(), validateParent()
Methods inherited from NObject
__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 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 NFormContainer
$currentGroup, $onValidate, $valid
Nette Framework 0.9.7 (for PHP 5.2) API documentation generated by ApiGen 2.3.0