jFormsBase

base class of all form classes generated by the jform compiler

package

jelix

subpackage

forms

Methods

__construct

__construct(string $sel, \jFormsDataContainer $container, boolean $reset = false) 

Arguments

$sel

string

the form selector

$container

\jFormsDataContainer

the data container

$reset

boolean

says if the data should be reset

_diffValues

_diffValues( &$v1,  &$v2) 

Arguments

$v1

$v2

declare a child control to the form. The given control should be a child of an other control

addChildControl(\jFormsControl $control) 

Arguments

$control

\jFormsControl

add a control to the form

addControl(\jFormsControl $control) 

Arguments

$control

\jFormsControl

the control to add

add a control to the form, before the specified control

addControlBefore(\jFormsControl $control, string $ref) 
since 1.1

Arguments

$control

\jFormsControl

the control to add

$ref

string

The ref of the control the new control should be inserted before

check validity of all data form

check() : boolean

Response

boolean

true if all is ok

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.

createNewToken() : string
since 1.1.2

Response

string

the token

deactivate (or reactivate) a control When a control is deactivated, it is not displayes anymore in the output form

deactivate(string $name, boolean $deactivation = true) 
Throws
\jExceptionForms

Arguments

$name

string

the name of the control

$deactivation

boolean

TRUE to deactivate, or FALSE to reactivate

getAllData

getAllData() : array

Response

array

form data

getBuilder

getBuilder(string $buildertype) : \jelix\forms\Builder\BuilderBase|\jFormsBuilderBase
Throws
\jExceptionForms

Arguments

$buildertype

string

the type name of a form builder. if the name begins by 'legacy.', it load a legacy builder plugin (jelix <=1.4)

Response

\jelix\forms\Builder\BuilderBase|\jFormsBuilderBase

getContainer

getContainer() : \jFormsDataContainer

getControl

getControl(string $name) : \jFormsControl
since

jelix 1.0

Arguments

$name

string

the control name you want to get

Response

\jFormsControl

getControls

getControls() : array

Response

array

of jFormsControl objects

getData

getData(string $name) : string

Arguments

$name

string

the name of the control/data

Response

string

the data value

return list of errors found during the check

getErrors() : array
see \jFormsBase::check

Response

array

getHiddens

getHiddens() : array
since 1.1

Response

array

of jFormsControl objects

getHtmlEditors

getHtmlEditors() : array
since 1.1

Response

array

of jFormsControl objects

returns the old values of the controls which have been modified since the call of the method initModifiedControlsList()

getModifiedControls() : array
since 1.1

Response

array

key=control id, value=old value

getReset

getReset() : \jFormsControl

Response

\jFormsControl

the reset object

getRootControls

getRootControls() : array

Response

array

of jFormsControl objects

getSelector

getSelector() 

getSubmits

getSubmits() : array

Response

array

of jFormsControl objects

getUploads

getUploads() : array
since 1.2

Response

array

of jFormsControl objects

getWikiEditors

getWikiEditors() : array
since 1.2

Response

array

of jFormsControl objects

hasUpload

hasUpload() : boolean

Response

boolean

id

id() : string

Response

string

the formId

set data from a DAO, in a control

initControlFromDao(string $name, string $daoSelector, mixed $primaryKey = null, mixed $primaryKeyNames = null, string $dbProfile = '') 

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.

see \jDao
Throws
\jExceptionForms

Arguments

$name

string

the name of the control

$daoSelector

string

the selector of a dao file

$primaryKey

mixed

the primary key if the form have no id. (optional)

$primaryKeyNames

mixed

list of field corresponding to primary keys (optional)

$dbProfile

string

the jDb profile to use with the dao

set form data from a DAO

initFromDao(string $daoSelector, string $key = null, string $dbProfile = '') : \jDaoRecordBase
see \jDao
Throws
\jExceptionForms

Arguments

$daoSelector

string

the selector of a dao file

$key

string

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

Response

\jDaoRecordBase

set form data from request parameters

initFromRequest() 

call this method after initilization of the form, in order to track modified controls

initModifiedControlsList() 
since 1.1

check if a control is activated

isActivated(string $name) : boolean

Arguments

$name

string

the control name

Response

boolean

true if it is activated

check if a control is readonly

isReadOnly( $name) : boolean

Arguments

$name

Response

boolean

true if it is readonly

prepare a dao with values of all controls

prepareDaoFromControls(string $daoSelector, string $key = null, string $dbProfile = '') : mixed
see \jDao

Arguments

$daoSelector

string

the selector of a dao file

$key

string

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

Response

mixed

return three vars : $daorec, $dao, $toInsert which have to be extracted

prepare an object with values of all controls

prepareObjectFromControls(object $object, array $properties = null) 

Arguments

$object

object

the object to fill

$properties

array

array of 'propertyname'=>array('required'=>true/false, 'defaultValue'=>$value, 'unifiedType'=>$datatype) values of datatype = same as jdb unified types

removeControl

removeControl( $name) 

Arguments

$name

save all uploaded file in the given directory

saveAllFiles(string $path = '') 

Arguments

$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

save data of a control using a dao.

saveControlToDao(string $controlName, string $daoSelector, mixed $primaryKey = null, mixed $primaryKeyNames = null, string $dbProfile = '') 

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.

see \jDao
Throws
\jExceptionForms

Arguments

$controlName

string

the name of the control

$daoSelector

string

the selector of a dao file

$primaryKey

mixed

the primary key if the form have no id. (optional)

$primaryKeyNames

mixed

list of field corresponding to primary keys (optional)

$dbProfile

string

the jDb profile to use with the dao

save an uploaded file in the given directory. the given control must be an upload control of course.

saveFile(string $controlName, string $path = '', string $alternateName = '') : boolean
Throws
\jExceptionForms

Arguments

$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

Response

boolean

true if the file has been saved correctly

save data using a dao.

saveToDao(string $daoSelector, string $key = null, string $dbProfile = '') : mixed

it call insert or update depending the value of the formId stored in the container

see \jDao

Arguments

$daoSelector

string

the selector of a dao file

$key

string

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

Response

mixed

the primary key of the new record in a case of inserting

setData

setData(string $name, string $value) 
Throws
\jExceptionForms

Arguments

$name

string

the name of the control/data

$value

string

the data value

set an error message on a specific field

setErrorOn(string $field, string $mesg) 

Arguments

$field

string

the field name

$mesg

string

the error message string

set a control readonly or not

setReadOnly( $name, boolean $r = true) 
Throws
\jExceptionForms

Arguments

$name

$r

boolean

true if you want read only

Constants

SECURITY_LOW

SECURITY_LOW

SECURITY_CSRF

SECURITY_CSRF

Properties

securityLevel

securityLevel : 

Type(s)

List of all form controls array of jFormsControl objects

controls : array
var
see

Type(s)

array

List of top controls array of jFormsControl objects

rootControls : array
var
see

Type(s)

array

List of submit buttons array of jFormsControl objects

submits : array
var
see

Type(s)

array

Reset button

reset : \jFormsControl
var
see
since

Type(s)

\jFormsControl

List of uploads controls array of jFormsControl objects

uploads : array
var
see

Type(s)

array

List of hidden controls array of jFormsControl objects

hiddens : array
var
see

Type(s)

array

List of htmleditorcontrols array of jFormsControl objects

htmleditors : array
var
see

Type(s)

array

List of wikieditorcontrols array of jFormsControl objects

wikieditors : array
var
see
since

Type(s)

array

the data container

container : \jFormsDataContainer
var

Type(s)

\jFormsDataContainer

content list of available form builder

builders : boolean
var

Type(s)

boolean

the form selector

sel : string
var

Type(s)

string