Class NForm
Creates, validates and renders HTML forms.
- NObject
-
NComponent implements IComponent
-
NComponentContainer implements IComponentContainer
-
NFormContainer implements ArrayAccess
-
NForm
Direct Known Subclasses
NAppFormExample: 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
NForm
|
#
getForm(
$need = true
)
Returns self. Returns self. |
public
NForm
|
#
setAction(
mixed
$url
)
Sets form's action. Sets form's action. Parameters$url mixed URIReturnsNForm provides a fluent interface
|
public
mixed
|
#
getAction(
)
Returns form's action. Returns form's action. Returnsmixed URI
|
public
NForm
|
#
setMethod(
string
$method
)
Sets form's method. Sets form's method. Parameters$method string get | postReturnsNForm 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
NFormGroup
|
#
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
NFormGroup
|
#
getGroup(
string
$name
)
Returns the specified group. Returns the specified group. Parameters$name string name |
public
NForm
|
#
setTranslator(
ITranslator
$translator = NULL
)
Sets translate adapter. Sets translate adapter. Parameters$translator ITranslatorReturnsNForm provides a fluent interface
|
final public
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
NForm
|
#
setSubmittedBy(
ISubmitterControl
$by = NULL
)
Sets the submittor control. Sets the submittor control. Parameters$by ISubmitterControlReturnsNForm 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
NHtml
|
#
getElementPrototype(
)
Returns form's HTML element template. Returns form's HTML element template. |
public
NForm
|
#
setRenderer(
IFormRenderer
$renderer
)
Sets form renderer. Sets form renderer. Parameters$renderer IFormRendererReturnsNForm 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
IHttpRequest
|
#
getHttpRequest(
)
|
protected
NSession
|
#
getSession(
)
|
Methods Inherited From NFormContainer
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 NComponentContainer
addComponent(), removeComponent(), getComponent(), createComponent(), getComponents(), validateChildComponent(), __clone()
Methods Inherited From NComponent
__construct(), lookup(), lookupPath(), monitor(), unmonitor(), attached(), detached(), getName(), getParent(), validateParent(), __clone(), __wakeup()
Methods Inherited From NObject
getReflection(), __call(), __callStatic(), extensionMethod(), __get(), __set(), __isset(), __unset()
EQUAL |
':equal' # |
IS_IN |
':equal' # |
FILLED |
':filled' # |
VALID |
':valid' # |
PROTECTION |
'NHiddenField::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 NComponent
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 NFormContainer
$onValidate, $currentGroup, $valid