Jelix 1.6.40

jForms
in package

static class to manage and call a form

A form is identified by a selector, and each instance of a form have a unique id (formId). This id can be the id of a record for example. If it is not given, the id is set to 0.

Tags
subpackage

forms

Table of Contents

DEFAULT_ID  = 0
ERRDATA_FILE_UPLOAD_ERROR  = 5
ERRDATA_INVALID  = 1
ERRDATA_INVALID_FILE_SIZE  = 3
ERRDATA_INVALID_FILE_TYPE  = 4
ERRDATA_REQUIRED  = 2
ID_PARAM  = '__forms_id__'
clean()  : mixed
destroy all form which are too old and unused
create()  : jFormsBase
Create a new form with empty data
destroy()  : mixed
destroy a form in the session
fill()  : jFormsBase
get an existing instance of a form, and fill it with data provided by the request
get()  : jFormsBase
get an existing instance of a form
__construct()  : mixed
pure static class, so no constructor

Constants

ERRDATA_FILE_UPLOAD_ERROR

public mixed ERRDATA_FILE_UPLOAD_ERROR = 5

ERRDATA_INVALID_FILE_SIZE

public mixed ERRDATA_INVALID_FILE_SIZE = 3

ERRDATA_INVALID_FILE_TYPE

public mixed ERRDATA_INVALID_FILE_TYPE = 4

Methods

clean()

destroy all form which are too old and unused

public static clean([mixed $formSel = '' ][, int $life = 86400 ]) : mixed
Parameters
$formSel : mixed = ''
$life : int = 86400

the number of second of a life of a form

Return values
mixed

create()

Create a new form with empty data

public static create(string $formSel[, string $formId = null ]) : jFormsBase

Call it to create a new form, before to display it. Data of the form are stored in the php session in a jFormsDataContainer object. If a form with same id exists, data are erased.

Parameters
$formSel : string

the selector of the xml jform file

$formId : string = null

the id of the new instance (an id of a record for example)

Return values
jFormsBase

the object representing the form

destroy()

destroy a form in the session

public static destroy(string $formSel[, string $formId = null ]) : mixed

use it after saving data of a form, and if you don't want to re-display the form.

Parameters
$formSel : string

the selector of the xml jform file

$formId : string = null

the id of the form (if you use multiple instance of a form)

Return values
mixed

fill()

get an existing instance of a form, and fill it with data provided by the request

public static fill(string $formSel[, string $formId = null ]) : jFormsBase

use it in the action called to submit a webform.

Parameters
$formSel : string

the selector of the xml jform file

$formId : string = null

the id of the form (if you use multiple instance of a form)

Return values
jFormsBase

the object representing the form. Return null if there isn't an existing form

get()

get an existing instance of a form

public static get(string $formSel[, string $formId = null ]) : jFormsBase

In your controller, call it before to re-display a form with existing data.

Parameters
$formSel : string

the selector of the xml jform file

$formId : string = null

the id of the form (if you use multiple instance of a form)

Return values
jFormsBase

the object representing the form. Return null if there isn't an existing form

__construct()

pure static class, so no constructor

private __construct() : mixed
Return values
mixed

Search results