Form
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 |
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
Form constructor.
No description
This method will be called when the component (or component's parent) becomes attached to a monitored object. Do not call this method yourself.
Returns form's action.
Returns form's method.
Checks if the request method is the given one.
Cross-Site Request Forgery (CSRF) form protection.
Adds fieldset group to the form.
Removes fieldset group from form.
Returns all defined groups.
Returns the specified group.
Sets translate adapter.
Returns translate adapter.
Tells if the form is anchored.
Tells if the form was submitted.
Tells if the form was submitted and successfully validated.
Returns submitted HTTP data.
Fires submit/click events.
Internal: returns submitted HTTP data or null when form was not submitted.
No description
No description
Adds global error message.
Returns global validation errors.
No description
No description
Returns form's validation errors.
Returns form's HTML element template.
Returns form renderer.
No description
Must be called before form is rendered and render() is not used.
Renders form.
Renders form to string.
No description
Details
at line 129
__construct($name = null)
Form constructor.
at line 145
protected void
validateParent(IContainer $parent)
No description
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.
at line 170
Form|null
getForm($throw = true)
Returns self.
at line 181
Form
setAction($url)
Sets form's action.
at line 192
mixed
getAction()
Returns form's action.
at line 203
Form
setMethod($method)
Sets form's method GET or POST.
at line 217
string
getMethod()
Returns form's method.
at line 228
bool
isMethod($method)
Checks if the request method is the given one.
at line 239
CsrfProtection
addProtection($errorMessage = null)
Cross-Site Request Forgery (CSRF) form protection.
at line 253
ControlGroup
addGroup($caption = null, $setAsCurrent = true)
Adds fieldset group to the form.
at line 276
void
removeGroup($name)
Removes fieldset group from form.
at line 301
ControlGroup[]
getGroups()
Returns all defined groups.
at line 312
ControlGroup|null
getGroup($name)
Returns the specified group.
at line 325
Form
setTranslator(ITranslator $translator = null)
Sets translate adapter.
at line 336
ITranslator|null
getTranslator()
Returns translate adapter.
at line 349
bool
isAnchored()
Tells if the form is anchored.
at line 359
ISubmitterControl|bool
isSubmitted()
Tells if the form was submitted.
at line 372
bool
isSuccess()
Tells if the form was submitted and successfully validated.
at line 383
Form
setSubmittedBy(ISubmitterControl $by = null)
internal |
Sets the submittor control.
at line 396
mixed
getHttpData($type = null, $htmlName = null)
Returns submitted HTTP data.
at line 417
void
fireEvents()
Fires submit/click events.
at line 475
Form
reset()
Resets form.
at line 487
protected array|null
receiveHttpData()
Internal: returns submitted HTTP data or null when form was not submitted.
at line 519
void
validate(array $controls = null)
No description
at line 531
validateMaxPostSize()
internal |
No description
at line 552
void
addError($message, $translate = true)
Adds global error message.
at line 565
array
getErrors()
Returns global validation errors.
at line 574
bool
hasErrors()
No description
at line 583
void
cleanErrors()
No description
at line 593
array
getOwnErrors()
Returns form's validation errors.
at line 606
Html
getElementPrototype()
Returns form's HTML element template.
at line 621
Form
setRenderer(IFormRenderer $renderer = null)
Sets form renderer.
at line 632
IFormRenderer
getRenderer()
Returns form renderer.
at line 644
protected void
beforeRender()
No description
at line 653
void
fireRenderEvents()
Must be called before form is rendered and render() is not used.
at line 670
void
render(...$args)
Renders form.
at line 682
string
__toString()
Renders form to string.
at line 719
array
getToggles()
No description