Jelix 1.6.37

jControllerDaoCrud extends jController
in package

a base class for crud controllers

Tags
subpackage

controllers

since
1.0b3

Table of Contents

$pluginParams  : array<string|int, mixed>
parameters for plugins of the coordinator
$sensitiveParameters  : array<string|int, string>
sensitive parameters
$dao  : string
selector of the dao to use for the crud.
$dbProfile  : mixed
the jDb profile to use with the dao
$editTemplate  : string
template to display the form
$form  : string
selector of the form to use to edit and display a record It should be filled by child controller.
$listPageSize  : int
number of record to display in the list page
$listTemplate  : string
template to display the list of records
$offsetParameterName  : string
name of the parameter which contains the page offset, for the index action
$propertiesForList  : array<string|int, string>
list of properties to show in the list page if empty list (default), it shows all properties.
$propertiesForRecordsOrder  : array<string|int, string>
list of properties which serve to order the record list.
$pseudoFormId  : string
id for the "pseudo" form used to show a record. You can change it if the default one corresponds to a possible id in your dao.
$request  : jRequest
the request object
$templateAssign  : string
the template variable name to display a CRUD content in the main template of the html response
$uploadsDirectory  : string|false
full path to the directory where uploaded files will be stored automatically by jForms.
$viewErrorTemplate  : string
template to show error when a record is not found
$viewTemplate  : string
template to display a record
__construct()  : mixed
create()  : mixed
display a form to create a record
delete()  : mixed
delete a record
editupdate()  : mixed
displays a forms to edit an existing record. The form should be prepared with the preupdate before, so a refresh of the page won't cause a reset of the form
index()  : mixed
list all records
precreate()  : mixed
prepare a form to create a record.
preupdate()  : mixed
prepare a form in order to edit an existing record, and redirect to the editupdate action
savecreate()  : mixed
save data of a form in a new record
saveupdate()  : mixed
save data of a form in a new record
view()  : mixed
displays a record
_afterCreate()  : mixed
redefine this method if you wan to do additionnal things after the creation of a record. For example, you can handle here the uploaded files. If you do such handling, set the uploadsDirectory property to false, to prevent the default behavior on uploaded files in the controller.
_afterUpdate()  : mixed
redefine this method if you wan to do additionnal things after the update of a record. For example, you can handle here the uploaded files. If you do such handling, set the uploadsDirectory property to false, to prevent the default behavior on uploaded files in the controller.
_beforeSaveCreate()  : mixed
redefine this method if you wan to do additionnal things on the dao generated by the jFormsBase::prepareDaoFromControls method
_beforeSaveUpdate()  : mixed
redefine this method if you wan to do additionnal things on the dao generated by the jFormsBase::prepareDaoFromControls method
_checkData()  : bool
you can do your own data check of a form by redefining this method.
_create()  : mixed
redefine this method if you want to do additionnal things on the response and on the edit template during the create action.
_createForm()  : jFormsBase
create the form. You can redefine this method to modify dynamically the form Typically, you call jForms::create and then you can call addControl or whatever.
_delete()  : bool
redefine this method if you want to do additionnal things before the deletion of a record
_editUpdate()  : mixed
redefine this method if you wan to do additionnal things on the response and on the edit template during the editupdate action.
_getAction()  : string
returned the selector of the action corresponding of the given method of the current controller.
_getForm()  : jFormsBase
get an existing form. You can redefine this method to modify dynamically the form Typically, you call jForms::get and then you can call addControl or whatever.
_getResponse()  : jResponseHtml
Returned a simple html response to display CRUD contents. You can redefine this method to return a personnalized response
_index()  : mixed
redefine this method if you wan to do additionnal things on the response and on the list template during the index action.
_indexSetConditions()  : mixed
redefine this method if you wan to do additionnal conditions to the index's select during the index action.
_preCreate()  : mixed
redefine this method if you want to do additionnal during the precreate action
_preUpdate()  : mixed
redefine this method if you want to do additionnal things during preupdate action
_view()  : mixed
redefine this method if you want to do additionnal things on the response and on the view template during the view action.
boolParam()  : bool
same as param(), but convert the value to a boolean value. If it isn't a numerical value, return null.
floatParam()  : float
same as param(), but convert the value to a float value. If it isn't a numerical value, return null.
getResponse()  : jResponse|jResponseHtml|jResponseRedirect|jResponseJson
get a response object.
intParam()  : int
same as param(), but convert the value to an integer value. If it isn't a numerical value, return null.
param()  : mixed
Gets the value of a request parameter. If not defined, gets its default value.
params()  : array<string|int, mixed>

Properties

$pluginParams

parameters for plugins of the coordinator

public array<string|int, mixed> $pluginParams = array()

this array should contains all parameters needed by installed plugins for each action, see the documentation of each plugins to know this parameters. keys : name of an action or * for parameters to all action values : array that contains all plugin parameters

$sensitiveParameters

sensitive parameters

public array<string|int, string> $sensitiveParameters = array()

List of names of parameters that can have sensitive values like password etc. This list is used by the logger for example, to replace values by a dummy value. See also sensitiveParameters into error_handling section of the configuration.

Tags
since
1.6.16

$dao

selector of the dao to use for the crud.

protected string $dao = ''

It should be filled by child controller.

$form

selector of the form to use to edit and display a record It should be filled by child controller.

protected string $form = ''

$listTemplate

template to display the list of records

protected string $listTemplate = 'jelix~crud_list'

$offsetParameterName

name of the parameter which contains the page offset, for the index action

protected string $offsetParameterName = 'offset'

$propertiesForList

list of properties to show in the list page if empty list (default), it shows all properties.

protected array<string|int, string> $propertiesForList = array()

this property is only usefull when you use the default "list" template

$propertiesForRecordsOrder

list of properties which serve to order the record list.

protected array<string|int, string> $propertiesForRecordsOrder = array()

if empty list (default), the list is in a natural order. keys are properties name, and values are "asc" or "desc".

$pseudoFormId

id for the "pseudo" form used to show a record. You can change it if the default one corresponds to a possible id in your dao.

protected string $pseudoFormId = 'jelix_crud_roxor'

$templateAssign

the template variable name to display a CRUD content in the main template of the html response

protected string $templateAssign = 'MAIN'

$uploadsDirectory

full path to the directory where uploaded files will be stored automatically by jForms.

protected string|false $uploadsDirectory = ''

Set it to false if you want to handle yourself the uploaded files. Set it with an empty string if you want to stored files in the default var/uploads directory.

$viewErrorTemplate

template to show error when a record is not found

protected string $viewErrorTemplate = 'jelix~404.html'
Tags
since
1.6.17

Methods

editupdate()

displays a forms to edit an existing record. The form should be prepared with the preupdate before, so a refresh of the page won't cause a reset of the form

public editupdate() : mixed
Return values
mixed

preupdate()

prepare a form in order to edit an existing record, and redirect to the editupdate action

public preupdate() : mixed
Return values
mixed

_afterCreate()

redefine this method if you wan to do additionnal things after the creation of a record. For example, you can handle here the uploaded files. If you do such handling, set the uploadsDirectory property to false, to prevent the default behavior on uploaded files in the controller.

protected _afterCreate(jFormsBase $form, mixed $id, jResponseHtml $resp) : mixed
Parameters
$form : jFormsBase

the form object

$id : mixed

the new id of the inserted record

$resp : jResponseHtml

the response

Return values
mixed

_afterUpdate()

redefine this method if you wan to do additionnal things after the update of a record. For example, you can handle here the uploaded files. If you do such handling, set the uploadsDirectory property to false, to prevent the default behavior on uploaded files in the controller.

protected _afterUpdate(jFormsBase $form, mixed $id, jResponseHtml $resp) : mixed
Parameters
$form : jFormsBase

the form object

$id : mixed

the new id of the updated record

$resp : jResponseHtml

the response

Return values
mixed

_beforeSaveUpdate()

redefine this method if you wan to do additionnal things on the dao generated by the jFormsBase::prepareDaoFromControls method

protected _beforeSaveUpdate(jFormsBase $form, jDaoRecordBase $form_daorec, mixed $id) : mixed
Parameters
$form : jFormsBase

the form

$form_daorec : jDaoRecordBase
$id : mixed

the new id of the updated record

Tags
since
1.1
Return values
mixed

_checkData()

you can do your own data check of a form by redefining this method.

protected _checkData(jFormsBase $form, bool $calltype) : bool

You can also do some other things. It is called only if the $form->check() is ok. and before the save of the data.

Parameters
$form : jFormsBase

the current form

$calltype : bool

true for an update, false for a create

Return values
bool

true if it is ok.

_create()

redefine this method if you want to do additionnal things on the response and on the edit template during the create action.

protected _create(jFormsBase $form, jResponseHtml $resp, jtpl $tpl) : mixed
Parameters
$form : jFormsBase

the form

$resp : jResponseHtml

the response

$tpl : jtpl

the template to display the edit form

Return values
mixed

_createForm()

create the form. You can redefine this method to modify dynamically the form Typically, you call jForms::create and then you can call addControl or whatever.

protected _createForm([string|int $formId = null ]) : jFormsBase

Don't do a jForms::get or jForms::fill in this method ! called in methods: index, precreate, create, preupdate, view

Parameters
$formId : string|int = null
Tags
since
1.1
Return values
jFormsBase

the form

_delete()

redefine this method if you want to do additionnal things before the deletion of a record

protected _delete(mixed $id, jResponseHtml $resp) : bool
Parameters
$id : mixed

the id of the record to delete

$resp : jResponseHtml

the response

Return values
bool

true if the record can be deleted

_editUpdate()

redefine this method if you wan to do additionnal things on the response and on the edit template during the editupdate action.

protected _editUpdate(jFormsBase $form, jResponseHtml $resp, jtpl $tpl) : mixed
Parameters
$form : jFormsBase

the form

$resp : jResponseHtml

the response

$tpl : jtpl

the template to display the edit form

Return values
mixed

_getAction()

returned the selector of the action corresponding of the given method of the current controller.

protected _getAction(string $method) : string
Parameters
$method : string

name of one of method of this controller

Return values
string

an action selector

_getForm()

get an existing form. You can redefine this method to modify dynamically the form Typically, you call jForms::get and then you can call addControl or whatever.

protected _getForm([string|int $formId = null ]) : jFormsBase

Don't do a jForms::create or jForms::fill in this method ! called in methods: create, savecreate, editupdate, saveupdate

Parameters
$formId : string|int = null
Tags
since
1.1
Return values
jFormsBase

the form

_index()

redefine this method if you wan to do additionnal things on the response and on the list template during the index action.

protected _index(jResponseHtml $resp, jtpl $tpl) : mixed
Parameters
$resp : jResponseHtml

the response

$tpl : jtpl

the template to display the record list

Return values
mixed

_indexSetConditions()

redefine this method if you wan to do additionnal conditions to the index's select during the index action.

protected _indexSetConditions(jDaoConditions $cond) : mixed
Parameters
$cond : jDaoConditions

the conditions

Return values
mixed

_preCreate()

redefine this method if you want to do additionnal during the precreate action

protected _preCreate(jFormsBase $form) : mixed
Parameters
$form : jFormsBase

the form

Tags
since
1.1
Return values
mixed

_preUpdate()

redefine this method if you want to do additionnal things during preupdate action

protected _preUpdate(jFormsBase $form) : mixed
Parameters
$form : jFormsBase

the form object

Tags
since
1.1
Return values
mixed

_view()

redefine this method if you want to do additionnal things on the response and on the view template during the view action.

protected _view(jFormsBase $form, jResponseHtml $resp, jtpl $tpl) : mixed
Parameters
$form : jFormsBase

the form

$resp : jResponseHtml

the response

$tpl : jtpl

the template to display the form content

Return values
mixed

boolParam()

same as param(), but convert the value to a boolean value. If it isn't a numerical value, return null.

protected boolParam(string $parName[, mixed $parDefaultValue = null ][, bool $useDefaultIfEmpty = false ]) : bool
Parameters
$parName : string

the name of the request parameter

$parDefaultValue : mixed = null

the default returned value if the parameter doesn't exists

$useDefaultIfEmpty : bool = false

true: says to return the default value the value is ""

Return values
bool

the request parameter value

floatParam()

same as param(), but convert the value to a float value. If it isn't a numerical value, return null.

protected floatParam(string $parName[, mixed $parDefaultValue = null ][, bool $useDefaultIfEmpty = false ]) : float
Parameters
$parName : string

the name of the request parameter

$parDefaultValue : mixed = null

the default returned value if the parameter doesn't exists

$useDefaultIfEmpty : bool = false

true: says to return the default value the value is ""

Return values
float

the request parameter value

intParam()

same as param(), but convert the value to an integer value. If it isn't a numerical value, return null.

protected intParam(string $parName[, mixed $parDefaultValue = null ][, bool $useDefaultIfEmpty = false ]) : int
Parameters
$parName : string

the name of the request parameter

$parDefaultValue : mixed = null

the default returned value if the parameter doesn't exists

$useDefaultIfEmpty : bool = false

true: says to return the default value the value is ""

Return values
int

the request parameter value

param()

Gets the value of a request parameter. If not defined, gets its default value.

protected param(string $parName[, mixed $parDefaultValue = null ][, bool $useDefaultIfEmpty = false ]) : mixed
Parameters
$parName : string

the name of the request parameter

$parDefaultValue : mixed = null

the default returned value if the parameter doesn't exists

$useDefaultIfEmpty : bool = false

true: says to return the default value if the parameter value is ""

Return values
mixed

the request parameter value

params()

protected params() : array<string|int, mixed>
Return values
array<string|int, mixed>

all request parameters

Search results