jFormsBase
in package
base class of all form classes generated by the jform compiler.
Tags
Table of Contents
- SECURITY_CSRF = 1
- SECURITY_LOW = 0
- $securityLevel : mixed
- $builders : bool
- content list of available form builder.
- $container : jFormsDataContainer
- the data container.
- $controls : array<string|int, jFormsControl>
- List of all form controls.
- $hiddens : array<string|int, jFormsControlHidden>
- List of hidden controls.
- $htmleditors : array<string|int, jFormsControlHtmlEditor>
- List of htmleditorcontrols.
- $reset : jFormsControlReset
- Reset button.
- $rootControls : array<string|int, jFormsControl>
- List of top controls.
- $sel : string
- the form selector.
- $submits : array<string|int, jFormsControlSubmit>
- List of submit buttons.
- $uploads : array<string|int, jFormsControlUpload2>|array<string|int, jFormsControlUpload>
- List of uploads controls.
- $wikieditors : array<string|int, jFormsControlWikiEditor>
- List of wikieditorcontrols.
- __construct() : mixed
- addChildControl() : mixed
- declare a child control to the form. The given control should be a child of an other control.
- addControl() : mixed
- add a control to the form.
- addControlBefore() : mixed
- add a control to the form, before the specified control.
- check() : bool
- check validity of all data form.
- createNewToken() : string
- generate a new token for security against CSRF a builder should call it and create for example an hidden input so jForms could verify it after the submit.
- deactivate() : mixed
- deactivate (or reactivate) a control When a control is deactivated, it is not displayes anymore in the output form.
- getAllData() : array<string|int, mixed>
- getBuilder() : BuilderBase|jFormsBuilderBase
- getContainer() : jFormsDataContainer
- getControl() : jFormsControl
- getControls() : array<string|int, jFormsControl>
- getData() : array<string|int, mixed>|string
- getErrors() : array<string|int, mixed>
- return list of errors found during the check.
- getHiddens() : array<string|int, jFormsControlHidden>
- getHtmlEditors() : array<string|int, jFormsControlHtmlEditor>
- getModifiedControls() : array<string|int, mixed>
- returns the old values of the controls which have been modified since the call of the method initModifiedControlsList().
- getReset() : jFormsControlReset
- getRootControls() : array<string|int, jFormsControl>
- getSelector() : string
- getSubmits() : array<string|int, jFormsControlSubmit>
- getUploads() : array<string|int, jFormsControlUpload2>|array<string|int, jFormsControlUpload>
- getWikiEditors() : array<string|int, jFormsControlWikiEditor>
- hasData() : bool
- hasUpload() : bool
- id() : string
- initControlFromDao() : mixed
- set data from a DAO, in a control.
- initFromDao() : jDaoRecordBase
- set form data from a DAO.
- initFromRequest() : mixed
- set form data from request parameters.
- initModifiedControlsList() : mixed
- call this method after initialization of the form, in order to track modified controls.
- isActivated() : bool
- check if a control is activated.
- isReadOnly() : bool
- check if a control is readonly.
- isValidToken() : bool
- Check if the valid token is the token created during the display of the form.
- prepareDaoFromControls() : array<string|int, mixed>
- prepare a dao with values of all controls.
- prepareObjectFromControls() : mixed
- prepare an object with values of all controls.
- removeControl() : mixed
- saveAllFiles() : mixed
- save all uploaded file in the given directory.
- saveControlToDao() : mixed
- save data of a control using a dao.
- saveFile() : bool
- save an uploaded file in the given directory. the given control must be an upload control of course.
- saveToDao() : mixed
- save data using a dao.
- setData() : mixed
- setErrorOn() : mixed
- set an error message on a specific field.
- setReadOnly() : mixed
- set a control readonly or not.
Constants
SECURITY_CSRF
public
mixed
SECURITY_CSRF
= 1
SECURITY_LOW
public
mixed
SECURITY_LOW
= 0
Properties
$securityLevel
public
mixed
$securityLevel
= 1
$builders
content list of available form builder.
protected
bool
$builders
= array()
$container
the data container.
protected
jFormsDataContainer
$container
$controls
List of all form controls.
protected
array<string|int, jFormsControl>
$controls
= array()
$hiddens
List of hidden controls.
protected
array<string|int, jFormsControlHidden>
$hiddens
= array()
$htmleditors
List of htmleditorcontrols.
protected
array<string|int, jFormsControlHtmlEditor>
$htmleditors
= array()
$reset
Reset button.
protected
jFormsControlReset
$reset
Tags
$rootControls
List of top controls.
protected
array<string|int, jFormsControl>
$rootControls
= array()
$sel
the form selector.
protected
string
$sel
$submits
List of submit buttons.
protected
array<string|int, jFormsControlSubmit>
$submits
= array()
$uploads
List of uploads controls.
protected
array<string|int, jFormsControlUpload2>|array<string|int, jFormsControlUpload>
$uploads
= array()
$wikieditors
List of wikieditorcontrols.
protected
array<string|int, jFormsControlWikiEditor>
$wikieditors
= array()
Tags
Methods
__construct()
public
__construct(string $sel, jFormsDataContainer $container[, bool $reset = false ]) : mixed
Parameters
- $sel : string
-
the form selector
- $container : jFormsDataContainer
-
the data container
- $reset : bool = false
-
says if the data should be reset
Return values
mixed —addChildControl()
declare a child control to the form. The given control should be a child of an other control.
public
addChildControl(jFormsControl $control) : mixed
Parameters
- $control : jFormsControl
Return values
mixed —addControl()
add a control to the form.
public
addControl(jFormsControl $control) : mixed
Parameters
- $control : jFormsControl
-
the control to add
Return values
mixed —addControlBefore()
add a control to the form, before the specified control.
public
addControlBefore(jFormsControl $control, string $ref) : mixed
Parameters
- $control : jFormsControl
-
the control to add
- $ref : string
-
The ref of the control the new control should be inserted before
Tags
Return values
mixed —check()
check validity of all data form.
public
check() : bool
Return values
bool —true if all is ok
createNewToken()
generate a new token for security against CSRF a builder should call it and create for example an hidden input so jForms could verify it after the submit.
public
createNewToken() : string
Tags
Return values
string —the token
deactivate()
deactivate (or reactivate) a control When a control is deactivated, it is not displayes anymore in the output form.
public
deactivate(string $name[, bool $deactivation = true ]) : mixed
Parameters
- $name : string
-
the name of the control
- $deactivation : bool = true
-
TRUE to deactivate, or FALSE to reactivate
Tags
Return values
mixed —getAllData()
public
getAllData() : array<string|int, mixed>
Return values
array<string|int, mixed> —form data
getBuilder()
public
getBuilder(string $buildertype) : BuilderBase|jFormsBuilderBase
Parameters
- $buildertype : string
-
the type name of a form builder. if the name begins by 'legacy.', it load a legacy builder plugin (jelix <=1.4)
Tags
Return values
BuilderBase|jFormsBuilderBase —getContainer()
public
getContainer() : jFormsDataContainer
Return values
jFormsDataContainer —getControl()
public
getControl(string $name) : jFormsControl
Parameters
- $name : string
-
the control name you want to get
Tags
Return values
jFormsControl —getControls()
public
getControls() : array<string|int, jFormsControl>
Return values
array<string|int, jFormsControl> —getData()
public
getData(string $name) : array<string|int, mixed>|string
Parameters
- $name : string
-
the name of the control/data
Return values
array<string|int, mixed>|string —the data value
getErrors()
return list of errors found during the check.
public
getErrors() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed> —getHiddens()
public
getHiddens() : array<string|int, jFormsControlHidden>
Tags
Return values
array<string|int, jFormsControlHidden> —getHtmlEditors()
public
getHtmlEditors() : array<string|int, jFormsControlHtmlEditor>
Tags
Return values
array<string|int, jFormsControlHtmlEditor> —getModifiedControls()
returns the old values of the controls which have been modified since the call of the method initModifiedControlsList().
public
getModifiedControls() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed> —key=control id, value=old value
getReset()
public
getReset() : jFormsControlReset
Return values
jFormsControlReset —the reset object
getRootControls()
public
getRootControls() : array<string|int, jFormsControl>
Return values
array<string|int, jFormsControl> —getSelector()
public
getSelector() : string
Return values
string —getSubmits()
public
getSubmits() : array<string|int, jFormsControlSubmit>
Return values
array<string|int, jFormsControlSubmit> —getUploads()
public
getUploads() : array<string|int, jFormsControlUpload2>|array<string|int, jFormsControlUpload>
Tags
Return values
array<string|int, jFormsControlUpload2>|array<string|int, jFormsControlUpload> —getWikiEditors()
public
getWikiEditors() : array<string|int, jFormsControlWikiEditor>
Tags
Return values
array<string|int, jFormsControlWikiEditor> —hasData()
public
hasData(string $name) : bool
Parameters
- $name : string
-
the name of the control/data
Return values
bool —true if there is a data with this name
hasUpload()
public
hasUpload() : bool
Return values
bool —id()
public
id() : string
Return values
string —the formId
initControlFromDao()
set data from a DAO, in a control.
public
initControlFromDao(string $name, string $daoSelector[, mixed $primaryKey = null ][, mixed $primaryKeyNames = null ][, string $dbProfile = '' ]) : mixed
The control must be a container like checkboxes or listbox with multiple attribute. The form should contain a formId
The Dao should map to an "association table" : its primary key should be composed by the primary key stored in the formId (or the given primarykey) + the field which will contain one of the values of the control. If this order is not the same as defined into the dao, you should provide the list of property names which corresponds to the primary key in this order : properties for the formId, followed by the property which contains the value.
Parameters
- $name : string
-
the name of the control
- $daoSelector : string
-
the selector of a dao file
- $primaryKey : mixed = null
-
the primary key if the form have no id. (optional)
- $primaryKeyNames : mixed = null
-
list of field corresponding to primary keys (optional)
- $dbProfile : string = ''
-
the jDb profile to use with the dao
Tags
Return values
mixed —initFromDao()
set form data from a DAO.
public
initFromDao(jDaoRecordBase|string $daoSelector[, string $key = null ][, string $dbProfile = '' ]) : jDaoRecordBase
Parameters
- $daoSelector : jDaoRecordBase|string
-
the selector of a dao file or a DAO record
- $key : string = null
-
the primary key for the dao. if null, takes the form ID as primary key. Only needed when string dao selector given.
- $dbProfile : string = ''
-
the jDb profile to use with the dao
Tags
Return values
jDaoRecordBase —initFromRequest()
set form data from request parameters.
public
initFromRequest() : mixed
Return values
mixed —initModifiedControlsList()
call this method after initialization of the form, in order to track modified controls.
public
initModifiedControlsList() : mixed
Tags
Return values
mixed —isActivated()
check if a control is activated.
public
isActivated(string $name) : bool
Parameters
- $name : string
-
the control name
Return values
bool —true if it is activated
isReadOnly()
check if a control is readonly.
public
isReadOnly(mixed $name) : bool
Parameters
- $name : mixed
Return values
bool —true if it is readonly
isValidToken()
Check if the valid token is the token created during the display of the form.
public
isValidToken(string $receivedToken) : bool
Parameters
- $receivedToken : string
Tags
Return values
bool —prepareDaoFromControls()
prepare a dao with values of all controls.
public
prepareDaoFromControls(string $daoSelector[, string $key = null ][, string $dbProfile = '' ]) : array<string|int, mixed>
Parameters
- $daoSelector : string
-
the selector of a dao file
- $key : string = null
-
the primary key for the dao. if null, takes the form ID as primary key
- $dbProfile : string = ''
-
the jDb profile to use with the dao
Tags
Return values
array<string|int, mixed> —return three vars : $daorec, $dao, $toInsert which have to be extracted
prepareObjectFromControls()
prepare an object with values of all controls.
public
prepareObjectFromControls(object $object[, array<string|int, mixed> $properties = null ]) : mixed
Parameters
- $object : object
-
the object to fill
- $properties : array<string|int, mixed> = null
-
array of 'propertyname'=>array('required'=>true/false, 'defaultValue'=>$value, 'unifiedType'=>$datatype) values of datatype = same as jdb unified types
Return values
mixed —removeControl()
public
removeControl(mixed $name) : mixed
Parameters
- $name : mixed
Return values
mixed —saveAllFiles()
save all uploaded file in the given directory.
public
saveAllFiles([string $path = '' ]) : mixed
Parameters
- $path : string = ''
-
path of the directory where to store the file. If it is not given, it will be stored under the var/uploads/modulename~formname/ directory
Return values
mixed —saveControlToDao()
save data of a control using a dao.
public
saveControlToDao(string $controlName, string $daoSelector[, mixed $primaryKey = null ][, mixed $primaryKeyNames = null ][, string $dbProfile = '' ]) : mixed
The control must be a container like checkboxes or listbox with multiple attribute. If the form contain a new record (no formId), you should call saveToDao before in order to get a new id (the primary key of the new record), or you should get a new id by an other way. then you must pass this primary key in the third argument. If the form has already a formId, then it will be used as a primary key, unless you give one in the third argument.
The Dao should map to an "association table" : its primary key should be the primary key stored in the formId + the field which will contain one of the values of the control. If this order is not the same as defined into the dao, you should provide the list of property names which corresponds to the primary key in this order : properties for the formId, followed by the property which contains the value. All existing records which have the formid in their keys are deleted before to insert new values.
Parameters
- $controlName : string
-
the name of the control
- $daoSelector : string
-
the selector of a dao file
- $primaryKey : mixed = null
-
the primary key if the form have no id. (optional)
- $primaryKeyNames : mixed = null
-
list of field corresponding to primary keys (optional)
- $dbProfile : string = ''
-
the jDb profile to use with the dao
Tags
Return values
mixed —saveFile()
save an uploaded file in the given directory. the given control must be an upload control of course.
public
saveFile(string $controlName[, string $path = '' ][, string $alternateName = '' ][, mixed $deletePreviousFile = true ]) : bool
Parameters
- $controlName : string
-
the name of the upload control
- $path : string = ''
-
path of the directory where to store the file. If it is not given, it will be stored under the var/uploads/modulename~formname/ directory
- $alternateName : string = ''
-
a new name for the file. If it is not given, the file while be stored with the original name
- $deletePreviousFile : mixed = true
Tags
Return values
bool —true if the file has been saved correctly
saveToDao()
save data using a dao.
public
saveToDao(string $daoSelector[, string $key = null ][, string $dbProfile = '' ]) : mixed
it call insert or update depending the value of the formId stored in the container.
Parameters
- $daoSelector : string
-
the selector of a dao file
- $key : string = null
-
the primary key for the dao. if null, takes the form ID as primary key
- $dbProfile : string = ''
-
the jDb profile to use with the dao
Tags
Return values
mixed —the primary key of the new record in a case of inserting
setData()
public
setData(string $name, string|array<string|int, string> $value) : mixed
Parameters
- $name : string
-
the name of the control/data
- $value : string|array<string|int, string>
-
the data value
Tags
Return values
mixed —setErrorOn()
set an error message on a specific field.
public
setErrorOn(string $field, string $mesg) : mixed
Parameters
- $field : string
-
the field name
- $mesg : string
-
the error message string
Return values
mixed —setReadOnly()
set a control readonly or not.
public
setReadOnly( $name[, bool $r = true ]) : mixed