Documentation

FlexFormInterface extends Serializable, FormInterface

Defines Forms for Flex Objects.

Tags
used-by

\Grav\Framework\Flex\FlexForm

since
1.6

Table of Contents

Methods

getAction()  : string
Get form action (URL). If action is empty, it points to the current page.
getBlueprint()  : Blueprint
Get blueprint used in the form.
getData()  : Data|object
Get current data passed to the form.
getError()  : string
getErrors()  : array<string|int, mixed>
getFields()  : array<string|int, mixed>
Get form fields as an array.
getFileDeleteAjaxRoute()  : Route|null
Get route for deleting files by AJAX.
getFiles()  : array<string|int, mixed>|array<string|int, UploadedFileInterface>
Get files which were passed to the form.
getFileUploadAjaxRoute()  : Route|null
Get route for uploading files by AJAX.
getFlash()  : FormFlashInterface
Get form flash object.
getFormName()  : string
Get form name.
getId()  : string
Get HTML id="..." attribute.
getMediaTaskRoute()  : string
Get media task route.
getName()  : string
getNonce()  : string
Get the nonce value for a form
getNonceAction()  : string
Get nonce action.
getNonceName()  : string
Get nonce name.
getTask()  : string
Get task for the form if set in blueprints.
getUniqueId()  : string
Get unique id for the current form instance. By default regenerated on every page reload.
getValue()  : mixed
Get a value from the form.
handleRequest()  : $this
isSubmitted()  : bool
isValid()  : bool
render()  : ContentBlockInterface|HtmlBlock
Renders the object.
reset()  : void
Reset form.
setId()  : void
Sets HTML id="" attribute.
setUniqueId()  : void
Sets unique form id.
submit()  : $this

Methods

getAction()

Get form action (URL). If action is empty, it points to the current page.

public getAction() : string
Return values
string

getData()

Get current data passed to the form.

public getData() : Data|object
Return values
Data|object

getErrors()

public getErrors() : array<string|int, mixed>
Return values
array<string|int, mixed>

getFields()

Get form fields as an array.

public getFields() : array<string|int, mixed>

Note: Used in form fields.

Return values
array<string|int, mixed>

getFileDeleteAjaxRoute()

Get route for deleting files by AJAX.

public getFileDeleteAjaxRoute(string|null $field, string|null $filename) : Route|null
Parameters
$field : string|null

Field where the file is associated into.

$filename : string|null

Filename for the file.

Return values
Route|null

Returns Route object or null if file uploads are not enabled.

getFiles()

Get files which were passed to the form.

public getFiles() : array<string|int, mixed>|array<string|int, UploadedFileInterface>
Return values
array<string|int, mixed>|array<string|int, UploadedFileInterface>

getFileUploadAjaxRoute()

Get route for uploading files by AJAX.

public getFileUploadAjaxRoute() : Route|null
Return values
Route|null

Returns Route object or null if file uploads are not enabled.

getFormName()

Get form name.

public getFormName() : string
Return values
string

getId()

Get HTML id="..." attribute.

public getId() : string
Return values
string

getMediaTaskRoute()

Get media task route.

public getMediaTaskRoute() : string
Return values
string

Returns admin route for media tasks.

getNonce()

Get the nonce value for a form

public getNonce() : string
Return values
string

getNonceAction()

Get nonce action.

public getNonceAction() : string
Return values
string

getNonceName()

Get nonce name.

public getNonceName() : string
Return values
string

getTask()

Get task for the form if set in blueprints.

public getTask() : string
Return values
string

getUniqueId()

Get unique id for the current form instance. By default regenerated on every page reload.

public getUniqueId() : string

This id is used to load the saved form state, if available.

Return values
string

getValue()

Get a value from the form.

public getValue(string $name) : mixed

Note: Used in form fields.

Parameters
$name : string

handleRequest()

public handleRequest(ServerRequestInterface $request) : $this
Parameters
$request : ServerRequestInterface
Return values
$this

isSubmitted()

public isSubmitted() : bool
Return values
bool

render()

Renders the object.

public render([string|null $layout = null ][, array<string|int, mixed> $context = [] ]) : ContentBlockInterface|HtmlBlock
APIYes
Parameters
$layout : string|null = null

Layout to be used.

$context : array<string|int, mixed> = []

Extra context given to the renderer.

Tags
example

$block = $object->render('custom', ['variable' => 'value']);

example

{% render object layout 'custom' with { variable: 'value' } %}

Return values
ContentBlockInterface|HtmlBlock

Returns HtmlBlock containing the rendered output.

setId()

Sets HTML id="" attribute.

public setId(string $id) : void
Parameters
$id : string

setUniqueId()

Sets unique form id.

public setUniqueId(string $uniqueId) : void
Parameters
$uniqueId : string

submit()

public submit(array<string|int, mixed> $data[, array<string|int, UploadedFileInterface>|null $files = null ]) : $this
Parameters
$data : array<string|int, mixed>
$files : array<string|int, UploadedFileInterface>|null = null
Return values
$this

        
On this page

Search results