namespace Nette\Forms
Class Form
Creates, validates and renders HTML forms.
- Nette\Object
-
Nette\Component implements Nette\IComponent
-
Nette\ComponentContainer implements Nette\IComponentContainer
-
Nette\Forms\FormContainer implements ArrayAccess
-
Nette\Forms\Form
Direct Known Subclasses
Nette\Application\AppFormExample: 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
Located at /Forms/Form.php
public
|
#
__construct(
string
$name = NULL
)
Form constructor. Form constructor. Parameters$name string |
protected
void
|
#
attached(
IComponent
$obj
)
This method will be called when the component (or component's parent) 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
Form
|
#
getForm(
$need = true
)
Returns self. Returns self. |
public
Form
|
#
setAction(
mixed
$url
)
Sets form's action. Sets form's action. Parameters$url mixed URIReturnsForm provides a fluent interface
|
public
mixed
|
#
getAction(
)
Returns form's action. Returns form's action. Returnsmixed URI
|
public
Form
|
#
setMethod(
string
$method
)
Sets form's method. Sets form's method. Parameters$method string get | postReturnsForm provides a fluent interface
|
public
string
|
#
getMethod(
)
Returns form's method. Returns form's method. Returnsstring get | post
|
public
void
|
#
addProtection(
string
$message = NULL,
int
$timeout = NULL
)
Cross-Site Request Forgery (CSRF) form protection. Cross-Site Request Forgery (CSRF) form protection. Parameters$message string$timeout int |
public
FormGroup
|
#
addGroup(
string
$caption = NULL,
bool
$setAsCurrent = true
)
Adds fieldset group to the form. Adds fieldset group to the form. Parameters$caption string caption$setAsCurrent bool set this group as current |
public
void
|
#
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. Returnsarray of FormGroup
|
public
FormGroup
|
#
getGroup(
string
$name
)
Returns the specified group. Returns the specified group. Parameters$name string name |
public
Form
|
#
setTranslator(
Nette\ITranslator
$translator = NULL
)
Sets translate adapter. Sets translate adapter. Parameters$translator Nette\ITranslatorReturnsForm provides a fluent interface
|
final public
Nette\ITranslator|NULL
|
#
getTranslator(
)
Returns translate adapter. Returns translate adapter. |
public
bool
|
#
isAnchored(
)
Tells if the form is anchored. Tells if the form is anchored. |
final public
ISubmitterControl|FALSE
|
#
isSubmitted(
)
Tells if the form was submitted. Tells if the form was submitted. ReturnsISubmitterControl|FALSE submittor control
|
public
Form
|
#
setSubmittedBy(
ISubmitterControl
$by = NULL
)
Sets the submittor control. Sets the submittor control. Parameters$by ISubmitterControlReturnsForm provides a fluent interface
|
final public
array
|
#
getHttpData(
)
Returns submitted HTTP data. Returns submitted HTTP data. |
public
void
|
#
fireEvents(
)
Fires submit/click events. Fires submit/click events. |
protected
array
|
#
receiveHttpData(
)
Internal: receives submitted HTTP data. Internal: receives submitted HTTP data. |
public
array
|
#
getValues(
)
Returns the values submitted by the form. Returns the values submitted by the form. |
public
void
|
#
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. |
public
bool
|
#
hasErrors(
)
|
public
void
|
#
cleanErrors(
)
|
public
Nette\Web\Html
|
#
getElementPrototype(
)
Returns form's HTML element template. Returns form's HTML element template. |
public
Form
|
#
setRenderer(
IFormRenderer
$renderer
)
Sets form renderer. Sets form renderer. Parameters$renderer IFormRendererReturnsForm provides a fluent interface
|
final public
IFormRenderer
|
#
getRenderer(
)
Returns form renderer. Returns form renderer. |
public
void
|
#
render(
)
Renders form. Renders form. |
public
string
|
#
__toString(
)
Renders form to string. Renders form to string. Returnsbool can throw exceptions? (hidden parameter)
|
protected
Nette\Web\IHttpRequest
|
#
getHttpRequest(
)
|
protected
Nette\Web\Session
|
#
getSession(
)
|
Methods Inherited From FormContainer
setDefaults(), setValues(), getValues(), isValid(), validate(), setCurrentGroup(), getCurrentGroup(), addComponent(), getControls(), getForm(), addText(), addPassword(), addTextArea(), addFile(), addHidden(), addCheckbox(), addRadioList(), addSelect(), addMultiSelect(), addSubmit(), addButton(), addImage(), addContainer(), offsetSet(), offsetGet(), offsetExists(), offsetUnset(), __clone()
Methods Inherited From Nette\ComponentContainer
addComponent(), removeComponent(), getComponent(), createComponent(), getComponents(), validateChildComponent(), __clone()
Methods Inherited From Nette\Component
__construct(), lookup(), lookupPath(), monitor(), unmonitor(), attached(), detached(), getName(), getParent(), validateParent(), __clone(), __wakeup()
Methods Inherited From Nette\Object
getReflection(), __call(), __callStatic(), extensionMethod(), __get(), __set(), __isset(), __unset()
EQUAL |
':equal' # |
IS_IN |
':equal' # |
FILLED |
':filled' # |
VALID |
':valid' # |
PROTECTION |
'Nette\\Forms\\HiddenField::validateEqual' # |
SUBMITTED |
':submitted' # |
MIN_LENGTH |
':minLength' # |
MAX_LENGTH |
':maxLength' # |
LENGTH |
':length' # |
EMAIL |
':email' # |
URL |
':url' # |
REGEXP |
':regexp' # |
PATTERN |
':pattern' # |
INTEGER |
':integer' # |
NUMERIC |
':integer' # |
FLOAT |
':float' # |
RANGE |
':range' # |
MAX_FILE_SIZE |
':fileSize' # |
MIME_TYPE |
':mimeType' # |
IMAGE |
':image' # |
GET |
'get' # |
POST |
'post' # |
TRACKER_ID |
'_form_' # |
PROTECTOR_ID |
'_token_' # |
Constants Inherited From Nette\Component
NAME_SEPARATOR
array
|
$onSubmit | NULL |
of function(Form $sender); Occurs when the form is submitted and successfully validated # |
array
|
$onInvalidSubmit | NULL |
of function(Form $sender); Occurs when the form is submitted and not validated # |
Properties Inherited From FormContainer
$onValidate, $currentGroup, $valid