class Form extends Container implements IHtmlString

Creates, validates and renders HTML forms.

Constants

EQUAL

validator

IS_IN

validator

NOT_EQUAL

validator

FILLED

validator

BLANK

validator

REQUIRED

validator

VALID

validator

deprecated PROTECTION

SUBMITTED

MIN_LENGTH

MAX_LENGTH

LENGTH

EMAIL

URL

PATTERN

INTEGER

NUMERIC

FLOAT

MIN

MAX

RANGE

COUNT

MAX_FILE_SIZE

MIME_TYPE

IMAGE

MAX_POST_SIZE

GET

method

POST

method

DATA_TEXT

submitted data types

DATA_LINE

DATA_FILE

DATA_KEYS

internal TRACKER_ID

internal PROTECTOR_ID

Properties

callable[] $onSuccess
callable[] $onError
callable[] $onSubmit
IRequest $httpRequest
array read-only $errors
Html read-only $elementPrototype

Methods

__construct($name = NULL)

Form constructor.

void
validateParent(IContainer $parent)

No description

void
attached($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.

getForm($need = TRUE)

Returns self.

setAction($url)

Sets form's action.

mixed
getAction()

Returns form's action.

setMethod($method)

Sets form's method.

string
getMethod()

Returns form's method.

addProtection($message = NULL)

Cross-Site Request Forgery (CSRF) form protection.

addGroup($caption = NULL, $setAsCurrent = TRUE)

Adds fieldset group to the form.

void
removeGroup($name)

Removes fieldset group from form.

getGroups()

Returns all defined groups.

getGroup($name)

Returns the specified group.

setTranslator(ITranslator $translator = NULL)

Sets translate adapter.

ITranslator|null
getTranslator()

Returns translate adapter.

bool
isAnchored()

Tells if the form is anchored.

isSubmitted()

Tells if the form was submitted.

bool
isSuccess()

Tells if the form was submitted and successfully validated.

setSubmittedBy(ISubmitterControl $by = NULL)

Sets the submittor control.

mixed
getHttpData($type = NULL, $htmlName = NULL)

Returns submitted HTTP data.

void
fireEvents()

Fires submit/click events.

array|null
receiveHttpData()

Internal: returns submitted HTTP data or NULL when form was not submitted.

void
validate(array $controls = NULL)

Performs the server side validation.

validateMaxPostSize()

No description

void
addError($message)

Adds global error message.

array
getErrors()

Returns global validation errors.

bool
hasErrors()

No description

void
cleanErrors()

No description

array
getOwnErrors()

Returns form's validation errors.

getAllErrors() deprecated

No description

Html
getElementPrototype()

Returns form's HTML element template.

setRenderer(IFormRenderer $renderer = NULL)

Sets form renderer.

getRenderer()

Returns form renderer.

void
render()

Renders form.

string
__toString()

Renders form to string.

array
getToggles()

No description

Details

at line 115
__construct($name = NULL)

Form constructor.

Parameters

$name

at line 130
protected void validateParent(IContainer $parent)

No description

Parameters

IContainer $parent

Return Value

void

at line 143
protected void attached($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.

Parameters

$obj

Return Value

void

at line 155
Form getForm($need = TRUE)

Returns self.

Parameters

$need

Return Value

Form

at line 166
Form setAction($url)

Sets form's action.

Parameters

$url

Return Value

Form

at line 177
mixed getAction()

Returns form's action.

Return Value

mixed URI

at line 188
Form setMethod($method)

Sets form's method.

Parameters

$method

Return Value

Form

at line 202
string getMethod()

Returns form's method.

Return Value

string

get | post

at line 213
CsrfProtection addProtection($message = NULL)

Cross-Site Request Forgery (CSRF) form protection.

Parameters

$message

Return Value

CsrfProtection

at line 225
ControlGroup addGroup($caption = NULL, $setAsCurrent = TRUE)

Adds fieldset group to the form.

Parameters

$caption
$setAsCurrent

Return Value

ControlGroup

at line 248
void removeGroup($name)

Removes fieldset group from form.

Parameters

$name

Return Value

void

at line 273
ControlGroup[] getGroups()

Returns all defined groups.

Return Value

ControlGroup[]

at line 284
ControlGroup getGroup($name)

Returns the specified group.

Parameters

$name

Return Value

ControlGroup

at line 297
Form setTranslator(ITranslator $translator = NULL)

Sets translate adapter.

Parameters

ITranslator $translator

Return Value

Form

at line 308
ITranslator|null getTranslator()

Returns translate adapter.

Return Value

ITranslator|null

at line 321
bool isAnchored()

Tells if the form is anchored.

Return Value

bool

at line 331
ISubmitterControl|false isSubmitted()

Tells if the form was submitted.

Return Value

ISubmitterControl|false

submittor control

at line 344
bool isSuccess()

Tells if the form was submitted and successfully validated.

Return Value

bool

at line 354
Form setSubmittedBy(ISubmitterControl $by = NULL)

Sets the submittor control.

Parameters

ISubmitterControl $by

Return Value

Form

at line 365
mixed getHttpData($type = NULL, $htmlName = NULL)

Returns submitted HTTP data.

Parameters

$type
$htmlName

Return Value

mixed

at line 386
void fireEvents()

Fires submit/click events.

Return Value

void

at line 425
protected array|null receiveHttpData()

Internal: returns submitted HTTP data or NULL when form was not submitted.

Return Value

array|null

at line 454
void validate(array $controls = NULL)

Performs the server side validation.

Parameters

array $controls

Return Value

void

at line 466
validateMaxPostSize()

internal  
 

No description

at line 487
void addError($message)

Adds global error message.

Parameters

$message

Return Value

void

at line 497
array getErrors()

Returns global validation errors.

Return Value

array

at line 506
bool hasErrors()

No description

Return Value

bool

at line 515
void cleanErrors()

No description

Return Value

void

at line 525
array getOwnErrors()

Returns form's validation errors.

Return Value

array

at line 532
getAllErrors() deprecated

deprecated

No description

at line 546
Html getElementPrototype()

Returns form's HTML element template.

Return Value

Html

at line 561
Form setRenderer(IFormRenderer $renderer = NULL)

Sets form renderer.

Parameters

IFormRenderer $renderer

Return Value

Form

at line 572
IFormRenderer getRenderer()

Returns form renderer.

Return Value

IFormRenderer

at line 585
void render()

Renders form.

Return Value

void

at line 598
string __toString()

Renders form to string.

Return Value

string

at line 634
array getToggles()

No description

Return Value

array