Class jFormsBase

Description

base class of all form classes generated by the jform compiler

  • abstract:

Located in /forms/jFormsBase.class.php (line 36)


	
			
Class Constant Summary
Variable Summary
Method Summary
jFormsBase __construct (string $sel, jFormsDataContainer $container, [boolean $reset = false])
void addChildControl (jFormsControl $control)
void addControl (jFormsControl $control)
void addControlBefore (jFormsControl $control, string $ref)
boolean check ()
string createNewToken ()
void deactivate (string $name, [boolean $deactivation = true])
array getAllData ()
jFormsBuilderBase getBuilder (string $buildertype)
jFormsControl getControl (string $name)
array getControls ()
string getData (string $name)
array getErrors ()
array getHiddens ()
array getHtmlEditors ()
array getReset ()
array getRootControls ()
void getSelector ()
array getSubmits ()
array getUploads ()
array getWikiEditors ()
boolean hasUpload ()
string id ()
void initControlFromDao (string $name, string $daoSelector, [mixed $primaryKey = null], [mixed $primaryKeyNames = null], [string $dbProfile = ''])
jDaoRecordBase initFromDao (string $daoSelector, [string $key = null], [string $dbProfile = ''])
void initFromRequest ()
boolean isActivated (string $name)
boolean isReadOnly ( $name)
mixed prepareDaoFromControls (string $daoSelector, [string $key = null], [string $dbProfile = ''])
void prepareObjectFromControls (object $object, [array $properties = null])
void removeControl ( $name)
void saveAllFiles ([string $path = ''])
void saveControlToDao (string $controlName, string $daoSelector, [mixed $primaryKey = null], [mixed $primaryKeyNames = null], [string $dbProfile = ''])
boolean saveFile (string $controlName, [string $path = ''], [string $alternateName = ''])
mixed saveToDao (string $daoSelector, [string $key = null], [string $dbProfile = ''])
void setData (string $name, string $value)
void setErrorOn (string $field, string $mesg)
void setReadOnly ( $name, [boolean $r = true])
void _diffValues ( &$v1,  &$v2)
Variables
boolean $builders = array() (line 118)

content list of available form builder

  • access: protected
jFormsDataContainer $container = null (line 112)

the data container

  • access: protected
array $controls = array() (line 49)

List of all form controls

array of jFormsControl objects

array $hiddens = array() (line 89)

List of hidden controls

array of jFormsControl objects

array $htmleditors = array() (line 97)

List of htmleditorcontrols

array of jFormsControl objects

jFormsControl $reset = null (line 73)

Reset button

array $rootControls = array() (line 57)

List of top controls

array of jFormsControl objects

mixed $securityLevel = 1 (line 41)
  • access: public
string $sel (line 124)

the form selector

  • access: protected
array $submits = array() (line 65)

List of submit buttons

array of jFormsControl objects

array $uploads = array() (line 81)

List of uploads controls

array of jFormsControl objects

array $wikieditors = array() (line 106)

List of wikieditorcontrols

array of jFormsControl objects

Methods
Constructor __construct (line 131)
  • access: public
jFormsBase __construct (string $sel, jFormsDataContainer $container, [boolean $reset = false])
  • string $sel: the form selector
  • jFormsDataContainer $container: the data container
  • boolean $reset: says if the data should be reset
addChildControl (line 818)

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

  • access: public
void addChildControl (jFormsControl $control)
addControl (line 768)

add a control to the form

  • access: public
void addControl (jFormsControl $control)
addControlBefore (line 784)

add a control to the form, before the specified control

  • since: 1.1
  • access: public
void addControlBefore (jFormsControl $control, string $ref)
  • jFormsControl $control: the control to add
  • string $ref: The ref of the control the new control should be inserted before
check (line 165)

check validity of all data form

  • return: true if all is ok
  • access: public
boolean check ()
createNewToken (line 861)

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.

  • return: the token
  • since: 1.1.2
  • access: public
string createNewToken ()
deactivate (line 505)

deactivate (or reactivate) a control

When a control is deactivated, it is not displayes anymore in the output form

  • access: public
void deactivate (string $name, [boolean $deactivation = true])
  • string $name: the name of the control
  • boolean $deactivation: TRUE to deactivate, or FALSE to reactivate
getAllData (line 497)
  • return: form data
  • access: public
array getAllData ()
getBuilder (line 685)
  • access: public
jFormsBuilderBase getBuilder (string $buildertype)
  • string $buildertype: the type name of a form builder
getContainer (line 544)
  • access: public
jFormsDataContainer getContainer ()
getControl (line 562)
  • since: jelix 1.0
  • access: public
jFormsControl getControl (string $name)
  • string $name: the control name you want to get
getControls (line 555)
  • return: of jFormsControl objects
  • access: public
array getControls ()
getData (line 488)
  • return: the data value
  • access: public
string getData (string $name)
  • string $name: the name of the control/data
getErrors (line 460)

return list of errors found during the check

  • see: jFormsBase::check
  • access: public
array getErrors ()
getHiddens (line 577)
  • return: of jFormsControl objects
  • since: 1.1
  • access: public
array getHiddens ()
getHtmlEditors (line 583)
  • return: of jFormsControl objects
  • since: 1.1
  • access: public
array getHtmlEditors ()
getModifiedControls (line 621)

returns the old values of the controls which have been modified since

the call of the method initModifiedControlsList()

  • return: key=control id, value=old value
  • since: 1.1
  • access: public
array getModifiedControls ()
getReset (line 669)
  • return: of jFormsControl objects
  • access: public
array getReset ()
getRootControls (line 550)
  • return: of jFormsControl objects
  • access: public
array getRootControls ()
getSelector (line 140)
  • access: public
void getSelector ()
getSubmits (line 571)
  • return: of jFormsControl objects
  • access: public
array getSubmits ()
getUploads (line 595)
  • return: of jFormsControl objects
  • since: 1.2
  • access: public
array getUploads ()
getWikiEditors (line 589)
  • return: of jFormsControl objects
  • since: 1.2
  • access: public
array getWikiEditors ()
hasUpload (line 679)
  • access: public
boolean hasUpload ()
id (line 674)
  • return: the formId
  • access: public
string id ()
initControlFromDao (line 343)

set data from a DAO, in a control

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
  • access: public
void initControlFromDao (string $name, string $daoSelector, [mixed $primaryKey = null], [mixed $primaryKeyNames = null], [string $dbProfile = ''])
  • string $name: the name of the control
  • string $daoSelector: the selector of a dao file
  • mixed $primaryKey: the primary key if the form have no id. (optional)
  • mixed $primaryKeyNames: list of field corresponding to primary keys (optional)
  • string $dbProfile: the jDb profile to use with the dao
initFromDao (line 256)

set form data from a DAO

  • see: jDao
  • access: public
jDaoRecordBase initFromDao (string $daoSelector, [string $key = null], [string $dbProfile = ''])
  • string $daoSelector: the selector of a dao file
  • string $key: the primary key for the dao. if null, takes the form ID as primary key
  • string $dbProfile: the jDb profile to use with the dao
initFromRequest (line 147)

set form data from request parameters

  • access: public
void initFromRequest ()
initModifiedControlsList (line 602)

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

modified controls

  • since: 1.1
  • access: public
void initModifiedControlsList ()
isActivated (line 517)

check if a control is activated

  • return: true if it is activated
  • access: public
boolean isActivated (string $name)
  • string $name: the control name
isReadOnly (line 537)

check if a control is readonly

  • return: true if it is readonly
  • access: public
boolean isReadOnly ( $name)
  • $name
prepareDaoFromControls (line 285)

prepare a dao with values of all controls

  • return: return three vars : $daorec, $dao, $toInsert which have to be extracted
  • see: jDao
  • access: public
mixed prepareDaoFromControls (string $daoSelector, [string $key = null], [string $dbProfile = ''])
  • string $daoSelector: the selector of a dao file
  • string $key: the primary key for the dao. if null, takes the form ID as primary key
  • string $dbProfile: the jDb profile to use with the dao
prepareObjectFromControls (line 181)

prepare an object with values of all controls

  • access: public
void prepareObjectFromControls (object $object, [array $properties = null])
  • object $object: the object to fill
  • array $properties: array of 'propertyname'=>array('required'=>true/false, 'defaultValue'=>$value, 'unifiedType'=>$datatype) values of datatype = same as jdb unified types
removeControl (line 798)
void removeControl ( $name)
  • $name
resetModifiedControlsList (line 611)

DEPRECATED. use initModifiedControlsList() instead.

  • deprecated: 1.1rc1
  • since: 1.1b1
  • access: public
void resetModifiedControlsList ()
saveAllFiles (line 743)

save all uploaded file in the given directory

  • access: public
void saveAllFiles ([string $path = ''])
  • string $path: 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
saveControlToDao (line 409)

save data of a control using a dao.

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
  • access: public
void saveControlToDao (string $controlName, string $daoSelector, [mixed $primaryKey = null], [mixed $primaryKeyNames = null], [string $dbProfile = ''])
  • string $controlName: the name of the control
  • string $daoSelector: the selector of a dao file
  • mixed $primaryKey: the primary key if the form have no id. (optional)
  • mixed $primaryKeyNames: list of field corresponding to primary keys (optional)
  • string $dbProfile: the jDb profile to use with the dao
saveFile (line 713)

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

  • return: true if the file has been saved correctly
  • access: public
boolean saveFile (string $controlName, [string $path = ''], [string $alternateName = ''])
  • string $controlName: the name of the upload control
  • string $path: 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
  • string $alternateName: a new name for the file. If it is not given, the file while be stored with the original name
saveToDao (line 312)

save data using a dao.

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

  • return: the primary key of the new record in a case of inserting
  • see: jDao
  • access: public
mixed saveToDao (string $daoSelector, [string $key = null], [string $dbProfile = ''])
  • string $daoSelector: the selector of a dao file
  • string $key: the primary key for the dao. if null, takes the form ID as primary key
  • string $dbProfile: the jDb profile to use with the dao
setData (line 476)
  • access: public
void setData (string $name, string $value)
  • string $name: the name of the control/data
  • string $value: the data value
setErrorOn (line 467)

set an error message on a specific field

  • access: public
void setErrorOn (string $field, string $mesg)
  • string $field: the field name
  • string $mesg: the error message string
setReadOnly (line 526)

set a control readonly or not

  • access: public
void setReadOnly ( $name, [boolean $r = true])
  • boolean $r: true if you want read only
  • $name
_diffValues (line 649)
  • access: protected
void _diffValues ( &$v1,  &$v2)
  • &$v1
  • &$v2
Class Constants
SECURITY_CSRF = 1 (line 39)
SECURITY_LOW = 0 (line 38)

Documentation generated on Mon, 19 Sep 2011 14:12:39 +0200 by phpDocumentor 1.4.3