Form
class Form extends Container implements HtmlStringable
Creates, validates and renders HTML forms.
Constants
Equal |
validator |
IsIn |
validator |
NotEqual |
validator |
IsNotIn |
validator |
Filled |
validator |
Blank |
validator |
Required |
validator |
Valid |
validator |
Submitted |
validator |
MinLength |
validator |
MaxLength |
validator |
Length |
validator |
validator |
|
URL |
validator |
Pattern |
validator |
PatternInsensitive |
validator |
Integer |
validator |
Numeric |
validator |
Float |
validator |
Min |
validator |
Max |
validator |
Range |
validator |
Count |
validator |
MaxFileSize |
validator |
MimeType |
validator |
Image |
validator |
MaxPostSize |
validator |
Get |
method |
Post |
method |
DataText |
submitted data types |
DataLine |
submitted data types |
DataFile |
submitted data types |
DataKeys |
submitted data types |
internal TrackerId |
|
internal ProtectorId |
|
deprecated EQUAL |
|
deprecated IS_IN |
|
deprecated NOT_EQUAL |
|
deprecated IS_NOT_IN |
|
deprecated FILLED |
|
deprecated BLANK |
|
deprecated REQUIRED |
|
deprecated VALID |
|
deprecated SUBMITTED |
|
deprecated MIN_LENGTH |
|
deprecated MAX_LENGTH |
|
deprecated LENGTH |
|
deprecated EMAIL |
|
deprecated PATTERN |
|
deprecated PATTERN_ICASE |
|
deprecated INTEGER |
|
deprecated NUMERIC |
|
deprecated FLOAT |
|
deprecated MIN |
|
deprecated MAX |
|
deprecated RANGE |
|
deprecated COUNT |
|
deprecated MAX_FILE_SIZE |
|
deprecated MIME_TYPE |
|
deprecated IMAGE |
|
deprecated MAX_POST_SIZE |
|
deprecated GET |
|
deprecated POST |
|
deprecated DATA_TEXT |
|
deprecated DATA_LINE |
|
deprecated DATA_FILE |
|
deprecated DATA_KEYS |
|
deprecated TRACKER_ID |
|
deprecated PROTECTOR_ID |
|
Properties
$onSuccess | Occurs when the form is submitted and successfully validated |
||
$onError | |||
$onSubmit | |||
$onRender | |||
internal | $httpRequest | ||
protected bool | $crossOrigin | ||
string | $action | ||
string | $method | ||
array read-only | $errors | ||
array read-only | $ownErrors | ||
Html read-only | $elementPrototype | ||
FormRenderer read-only | $renderer |
Methods
No description
Returns self.
Returns form's action.
Returns form's method.
Checks if the request method is the given one.
Changes forms's HTML attribute.
Disables CSRF protection using a SameSite cookie.
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.
Sets the submittor control.
Returns submitted HTTP data.
Fires submit/click events.
Internal: returns submitted HTTP data or null when form was not submitted.
Performs the server side validation.
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.
Sets form renderer.
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
Initialize standalone forms.
Details
at line 221
__construct(string|null $name = null)
No description
at line 240
Form|null
getForm(bool $throw = true)
Returns self.
at line 249
Form
setAction(string|Stringable $url)
Sets form's action.
at line 259
string|Stringable
getAction()
Returns form's action.
at line 268
Form
setMethod(string $method)
Sets form's method GET or POST.
at line 282
string
getMethod()
Returns form's method.
at line 291
bool
isMethod(string $method)
Checks if the request method is the given one.
at line 300
Form
setHtmlAttribute(string $name, mixed $value = true)
Changes forms's HTML attribute.
at line 310
void
allowCrossOrigin()
Disables CSRF protection using a SameSite cookie.
at line 319
CsrfProtection
addProtection(string|null $errorMessage = null)
Cross-Site Request Forgery (CSRF) form protection.
at line 332
ControlGroup
addGroup(string|Stringable|null $caption = null, bool $setAsCurrent = true)
Adds fieldset group to the form.
at line 351
void
removeGroup(ControlGroup $name)
Removes fieldset group from form.
at line 376
array
getGroups()
Returns all defined groups.
at line 385
ControlGroup|null
getGroup(string|int $name)
Returns the specified group.
at line 397
Form
setTranslator(Translator|null $translator)
Sets translate adapter.
at line 407
Translator|null
getTranslator()
Returns translate adapter.
at line 419
bool
isAnchored()
Tells if the form is anchored.
at line 428
SubmitterControl|bool
isSubmitted()
Tells if the form was submitted.
at line 441
bool
isSuccess()
Tells if the form was submitted and successfully validated.
at line 451
Form
setSubmittedBy(SubmitterControl|null $by)
internal |
Sets the submittor control.
at line 461
FileUpload|null
getHttpData(int|null $type = null, string|null $htmlName = null)
Returns submitted HTTP data.
at line 483
void
fireEvents()
Fires submit/click events.
at line 549
Form
reset()
Resets form.
at line 560
protected array|null
receiveHttpData()
Internal: returns submitted HTTP data or null when form was not submitted.
at line 593
void
validate(array|null $controls = null)
Performs the server side validation.
at line 606
void
validateMaxPostSize()
internal |
No description
at line 622
void
addError(string|Stringable $message, bool $translate = true)
Adds global error message.
at line 635
array
getErrors()
Returns global validation errors.
at line 641
bool
hasErrors()
No description
at line 647
void
cleanErrors()
No description
at line 656
array
getOwnErrors()
Returns form's validation errors.
at line 668
Html
getElementPrototype()
Returns form's HTML element template.
at line 683
Form
setRenderer(FormRenderer|null $renderer)
Sets form renderer.
at line 693
FormRenderer
getRenderer()
Returns form renderer.
at line 703
protected
beforeRender()
No description
at line 711
void
fireRenderEvents()
Must be called before form is rendered and render() is not used.
at line 724
void
render(...$args)
Renders form.
at line 734
string
__toString()
Renders form to string.
at line 741
array
getToggles()
No description
at line 760
static void
initialize(bool $reinit = false)
Initialize standalone forms.