class Form extends Container implements IHtmlString

Creates, validates and renders HTML forms.

Constants

EQUAL

validator

IS_IN

validator

NOT_EQUAL

validator

IS_NOT_IN

validator

FILLED

validator

BLANK

validator

REQUIRED

validator

VALID

validator

SUBMITTED

validator

MIN_LENGTH

validator

MAX_LENGTH

validator

LENGTH

validator

EMAIL

validator

URL

validator

PATTERN

validator

PATTERN_ICASE

validator

INTEGER

validator

NUMERIC

validator

FLOAT

validator

MIN

validator

MAX

validator

RANGE

validator

COUNT

validator

MAX_FILE_SIZE

validator

MIME_TYPE

validator

IMAGE

validator

MAX_POST_SIZE

validator

deprecated PROTECTION

GET

method

POST

method

DATA_TEXT

submitted data types

DATA_LINE

submitted data types

DATA_FILE

submitted data types

DATA_KEYS

submitted data types

internal TRACKER_ID

internal PROTECTOR_ID

Properties

callable[] $onSuccess
callable[] $onError
callable[] $onSubmit
callable[] $onRender
IRequest $httpRequest
string $action
string $method
array read-only $errors
array read-only $ownErrors
Html read-only $elementPrototype
IFormRenderer read-only $renderer

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.

Form|null
getForm($throw = true)

Returns form.

setAction($url)

Sets form's action.

mixed
getAction()

Returns form's action.

setMethod($method)

Sets form's method GET or POST.

string
getMethod()

Returns form's method.

bool
isMethod($method)

Checks if the request method is the given one.

addProtection($errorMessage = 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.

reset()

Resets form.

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, $translate = true)

Adds global error message.

array
getErrors()

Returns all validation errors.

bool
hasErrors()

No description

void
cleanErrors()

No description

array
getOwnErrors()

Returns form's validation errors.

Html
getElementPrototype()

Returns form's HTML element template.

setRenderer(IFormRenderer $renderer = null)

Sets form renderer.

getRenderer()

Returns form renderer.

void
beforeRender()

No description

void
fireRenderEvents()

Must be called before form is rendered and render() is not used.

void
render(...$args)

Renders form.

string
__toString()

Renders form to string.

array
getToggles()

No description

Details

at line 129
__construct($name = null)

Form constructor.

Parameters

$name

at line 145
protected void validateParent(IContainer $parent)

No description

Parameters

IContainer $parent

Return Value

void

at line 158
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 170
Form|null getForm($throw = true)

Returns form.

Parameters

$throw

Return Value

Form|null

at line 181
Form setAction($url)

Sets form's action.

Parameters

$url

Return Value

Form

at line 192
mixed getAction()

Returns form's action.

Return Value

mixed

at line 203
Form setMethod($method)

Sets form's method GET or POST.

Parameters

$method

Return Value

Form

at line 217
string getMethod()

Returns form's method.

Return Value

string

at line 228
bool isMethod($method)

Checks if the request method is the given one.

Parameters

$method

Return Value

bool

at line 239
CsrfProtection addProtection($errorMessage = null)

Cross-Site Request Forgery (CSRF) form protection.

Parameters

$errorMessage

Return Value

CsrfProtection

at line 253
ControlGroup addGroup($caption = null, $setAsCurrent = true)

Adds fieldset group to the form.

Parameters

$caption
$setAsCurrent

Return Value

ControlGroup

at line 276
void removeGroup($name)

Removes fieldset group from form.

Parameters

$name

Return Value

void

at line 301
ControlGroup[] getGroups()

Returns all defined groups.

Return Value

ControlGroup[]

at line 312
ControlGroup|null getGroup($name)

Returns the specified group.

Parameters

$name

Return Value

ControlGroup|null

at line 325
Form setTranslator(ITranslator $translator = null)

Sets translate adapter.

Parameters

ITranslator $translator

Return Value

Form

at line 336
ITranslator|null getTranslator()

Returns translate adapter.

Return Value

ITranslator|null

at line 349
bool isAnchored()

Tells if the form is anchored.

Return Value

bool

at line 359
ISubmitterControl|bool isSubmitted()

Tells if the form was submitted.

Return Value

ISubmitterControl|bool

submittor control

at line 372
bool isSuccess()

Tells if the form was submitted and successfully validated.

Return Value

bool

at line 383
Form setSubmittedBy(ISubmitterControl $by = null)

internal  
 

Sets the submittor control.

Parameters

ISubmitterControl $by

Return Value

Form

at line 396
mixed getHttpData($type = null, $htmlName = null)

Returns submitted HTTP data.

Parameters

$type
$htmlName

Return Value

mixed

at line 417
void fireEvents()

Fires submit/click events.

Return Value

void

at line 475
Form reset()

Resets form.

Return Value

Form

at line 487
protected array|null receiveHttpData()

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

Return Value

array|null

at line 519
void validate(array $controls = null)

Performs the server side validation.

Parameters

array $controls

Return Value

void

at line 531
validateMaxPostSize()

internal  
 

No description

at line 552
void addError($message, $translate = true)

Adds global error message.

Parameters

$message
$translate

Return Value

void

at line 565
array getErrors()

Returns all validation errors.

Return Value

array

at line 574
bool hasErrors()

No description

Return Value

bool

at line 583
void cleanErrors()

No description

Return Value

void

at line 593
array getOwnErrors()

Returns form's validation errors.

Return Value

array

at line 606
Html getElementPrototype()

Returns form's HTML element template.

Return Value

Html

at line 621
Form setRenderer(IFormRenderer $renderer = null)

Sets form renderer.

Parameters

IFormRenderer $renderer

Return Value

Form

at line 632
IFormRenderer getRenderer()

Returns form renderer.

Return Value

IFormRenderer

at line 644
protected void beforeRender()

No description

Return Value

void

at line 653
void fireRenderEvents()

Must be called before form is rendered and render() is not used.

Return Value

void

at line 670
void render(...$args)

Renders form.

Parameters

...$args

Return Value

void

at line 682
string __toString()

Renders form to string.

Return Value

string

at line 719
array getToggles()

No description

Return Value

array