PHP Class Nette\Forms\Form

Author: David Grudl
Inheritance: extends Container
Show file Open project: nette/forms Class Usage Examples

Public Properties

Property Type Description
$httpRequest used only by standalone form
$onError function (Form $sender); Occurs when the form is submitted and is not valid
$onRender function (Form $sender); Occurs before the form is rendered
$onSubmit function (Form $sender); Occurs when the form is submitted
$onSuccess function (Form $sender); Occurs when the form is submitted and successfully validated

Public Methods

Method Description
__construct ( $name = NULL ) Form constructor.
__toString ( ) : string Renders form to string.
addError ( $message ) : void Adds global error message.
addGroup ( $caption = NULL, $setAsCurrent = TRUE ) : ControlGroup Adds fieldset group to the form.
addProtection ( $message = NULL ) : CsrfProtection Cross-Site Request Forgery (CSRF) form protection.
cleanErrors ( ) : void
fireEvents ( ) : void Fires submit/click events.
fireRenderEvents ( ) : void Must be called before form is rendered and render() is not used.
getAction ( ) : mixed Returns form's action.
getElementPrototype ( ) : Nette\Utils\Html Returns form's HTML element template.
getErrors ( ) : array Returns global validation errors.
getForm ( $need = TRUE ) : self Returns self.
getGroup ( $name ) : ControlGroup Returns the specified group.
getGroups ( ) : ControlGroup[] Returns all defined groups.
getHttpData ( $type = NULL, $htmlName = NULL ) : mixed Returns submitted HTTP data.
getMethod ( ) : string Returns form's method.
getOwnErrors ( ) : array Returns form's validation errors.
getRenderer ( ) : Nette\Forms\IFormRenderer Returns form renderer.
getToggles ( ) : array
getTranslator ( ) : Nette\Localization\ITranslator | null Returns translate adapter.
hasErrors ( ) : boolean
isAnchored ( ) : boolean Tells if the form is anchored.
isMethod ( $method ) : boolean Checks if the request method is the given one.
isSubmitted ( ) : Nette\Forms\ISubmitterControl | FALSE Tells if the form was submitted.
isSuccess ( ) : boolean Tells if the form was submitted and successfully validated.
removeGroup ( $name ) : void Removes fieldset group from form.
render ( $args ) : void Renders form.
setAction ( $url ) : self Sets form's action.
setMethod ( $method ) : self Sets form's method.
setRenderer ( Nette\Forms\IFormRenderer $renderer = NULL ) : self Sets form renderer.
setSubmittedBy ( Nette\Forms\ISubmitterControl $by = NULL ) : self Sets the submittor control.
setTranslator ( Nette\Localization\ITranslator $translator = NULL ) : self Sets translate adapter.
validate ( array $controls = NULL ) ******************* validation ****************d*g*
validateMaxPostSize ( )

Protected Methods

Method Description
attached ( $obj ) : 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.
beforeRender ( ) : void
receiveHttpData ( ) : array | null Internal: returns submitted HTTP data or NULL when form was not submitted.
validateParent ( Nette\ComponentModel\IContainer $parent ) : void

Private Methods

Method Description
getHttpRequest ( ) : Nette\Http\IRequest

Method Details

__construct() public method

Form constructor.
public __construct ( $name = NULL )

__toString() public method

Renders form to string.
public __toString ( ) : string
return string

addError() public method

Adds global error message.
public addError ( $message ) : void
return void

addGroup() public method

Adds fieldset group to the form.
public addGroup ( $caption = NULL, $setAsCurrent = TRUE ) : ControlGroup
return ControlGroup

addProtection() public method

Cross-Site Request Forgery (CSRF) form protection.
public addProtection ( $message = NULL ) : CsrfProtection
return Nette\Forms\Controls\CsrfProtection

attached() protected method

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 attached ( $obj ) : void
return void

beforeRender() protected method

protected beforeRender ( ) : void
return void

cleanErrors() public method

public cleanErrors ( ) : void
return void

fireEvents() public method

Fires submit/click events.
public fireEvents ( ) : void
return void

fireRenderEvents() public method

Must be called before form is rendered and render() is not used.
public fireRenderEvents ( ) : void
return void

getAction() public method

Returns form's action.
public getAction ( ) : mixed
return mixed URI

getElementPrototype() public method

Returns form's HTML element template.
public getElementPrototype ( ) : Nette\Utils\Html
return Nette\Utils\Html

getErrors() public method

Returns global validation errors.
public getErrors ( ) : array
return array

getForm() public method

Returns self.
public getForm ( $need = TRUE ) : self
return self

getGroup() public method

Returns the specified group.
public getGroup ( $name ) : ControlGroup
return ControlGroup

getGroups() public method

Returns all defined groups.
public getGroups ( ) : ControlGroup[]
return ControlGroup[]

getHttpData() public method

Returns submitted HTTP data.
public getHttpData ( $type = NULL, $htmlName = NULL ) : mixed
return mixed

getMethod() public method

Returns form's method.
public getMethod ( ) : string
return string get | post

getOwnErrors() public method

Returns form's validation errors.
public getOwnErrors ( ) : array
return array

getRenderer() public method

Returns form renderer.
public getRenderer ( ) : Nette\Forms\IFormRenderer
return Nette\Forms\IFormRenderer

getToggles() public method

public getToggles ( ) : array
return array

getTranslator() public method

Returns translate adapter.
public getTranslator ( ) : Nette\Localization\ITranslator | null
return Nette\Localization\ITranslator | null

hasErrors() public method

public hasErrors ( ) : boolean
return boolean

isAnchored() public method

Tells if the form is anchored.
public isAnchored ( ) : boolean
return boolean

isMethod() public method

Checks if the request method is the given one.
public isMethod ( $method ) : boolean
return boolean

isSubmitted() public method

Tells if the form was submitted.
public isSubmitted ( ) : Nette\Forms\ISubmitterControl | FALSE
return Nette\Forms\ISubmitterControl | FALSE submittor control

isSuccess() public method

Tells if the form was submitted and successfully validated.
public isSuccess ( ) : boolean
return boolean

receiveHttpData() protected method

Internal: returns submitted HTTP data or NULL when form was not submitted.
protected receiveHttpData ( ) : array | null
return array | null

removeGroup() public method

Removes fieldset group from form.
public removeGroup ( $name ) : void
return void

render() public method

Renders form.
public render ( $args ) : void
return void

setAction() public method

Sets form's action.
public setAction ( $url ) : self
return self

setMethod() public method

Sets form's method.
public setMethod ( $method ) : self
return self

setRenderer() public method

Sets form renderer.
public setRenderer ( Nette\Forms\IFormRenderer $renderer = NULL ) : self
$renderer Nette\Forms\IFormRenderer
return self

setSubmittedBy() public method

Sets the submittor control.
public setSubmittedBy ( Nette\Forms\ISubmitterControl $by = NULL ) : self
$by Nette\Forms\ISubmitterControl
return self

setTranslator() public method

Sets translate adapter.
public setTranslator ( Nette\Localization\ITranslator $translator = NULL ) : self
$translator Nette\Localization\ITranslator
return self

validate() public method

******************* validation ****************d*g*
public validate ( array $controls = NULL )
$controls array

validateMaxPostSize() public method

public validateMaxPostSize ( )

validateParent() protected method

protected validateParent ( Nette\ComponentModel\IContainer $parent ) : void
$parent Nette\ComponentModel\IContainer
return void

Property Details

$httpRequest public property

used only by standalone form
public $httpRequest

$onError public property

function (Form $sender); Occurs when the form is submitted and is not valid
public $onError

$onRender public property

function (Form $sender); Occurs before the form is rendered
public $onRender

$onSubmit public property

function (Form $sender); Occurs when the form is submitted
public $onSubmit

$onSuccess public property

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