dolibarr 23.0.3
FieldsManager Class Reference

Class to manage fields. More...

Inheritance diagram for FieldsManager:
Collaboration diagram for FieldsManager:

Public Member Functions

 __construct ($db, $form=null)
 Constructor.
 
 getFieldClass ($type)
 Get field handler for the provided type.
 
 getAllFields ()
 Get all fields handler available.
 
 clearErrors ()
 clear errors
 
 errorsToString ($separator=', ')
 Method to output saved errors.
 
 clearFieldError ($fieldKey)
 clear validation message result for a field
 
 setFieldError ($fieldKey, $msg='')
 set validation error message a field
 
 getFieldError ($fieldKey)
 get field error message
 
 getFieldErrorIcon ($fieldValidationErrorMsg)
 get field error icon
 
 getAllFieldsInfos (&$object, &$extrafields=null, $mode='view', $nbColumn=2, $breakKeys=array(), $params=array())
 Get list of fields infos for the provided mode into X columns.
 
 getAllObjectFieldsInfos (&$object, $mode='view', $params=array())
 Get list of object fields infos.
 
 getAllExtraFieldsInfos (&$object, &$extrafields=null, $mode='view', $params=array())
 Get list of extra fields infos.
 
 getFieldsInfos ($key, &$object, &$extrafields=null, $mode='view', $params=array())
 Get list of fields infos for the provided mode into X columns.
 
 getFieldInfosFromObjectField (&$object, $key, $mode='view', $params=array())
 Get field infos from object field infos.
 
 getFieldInfosFromExtraField (&$object, &$extrafields, $key, $mode='view', $params=array())
 Get field infos from extra field infos.
 
 setCommonFieldInfos (&$fieldInfos, &$object, &$extrafields, $key, $mode='view', $enabled='1', $visibility='', $perms=null, $params=array())
 Set common field infos.
 
 setFieldValuesFromPost (&$object, &$extrafields, $keyPrefix='', $keySuffix='', $mode='view', $params=array())
 Set all values of the object (with extra field) from POST.
 
 setObjectFieldValuesFromPost (&$object, $keyPrefix='', $keySuffix='', $mode='view', $params=array())
 Set all object values of the object from POST.
 
 setExtraFieldValuesFromPost (&$object, &$extrafields, $keyPrefix='', $keySuffix='', $mode='view', $params=array())
 Set all extra field values of the object from POST.
 
 verifyPostFieldValue ($fieldInfos, $key, $keyPrefix='', $keySuffix='')
 Verify if the field value is valid.
 
 verifyFieldValue ($fieldInfos, $key, $value)
 Verify if the field value is valid.
 
 getPostFieldValue ($fieldInfos, $key, $defaultValue=null, $keyPrefix='', $keySuffix='')
 Get field value from GET/POST.
 
 getPostSearchFieldValue ($fieldInfos, $key, $defaultValue=null, $keyPrefix='', $keySuffix='')
 Get search field value from GET/POST.
 
 printInputSearchField ($fieldInfos, $key, $value, $keyPrefix='', $keySuffix='', $moreCss='', $moreAttrib='', $noNewButton=0)
 Return HTML string to put an input search field into a page.
 
 printInputField ($fieldInfos, $key, $value, $keyPrefix='', $keySuffix='', $moreCss='', $moreAttrib='', $noNewButton=0)
 Return HTML string to put an input field into a page.
 
 printOutputField ($fieldInfos, $key, $value, $keyPrefix='', $keySuffix='', $moreCss='', $moreAttrib='')
 Return HTML string to show a field into a page.
 
 printSeparator ($key, &$object, $colspan=2, $display_type='card', $mode='view')
 Return HTML string to print separator field.
 

Detailed Description

Class to manage fields.

Definition at line 42 of file fieldsmanager.class.php.

Constructor & Destructor Documentation

◆ __construct()

FieldsManager::__construct ( $db,
$form = null )

Constructor.

Parameters
DoliDB$dbDatabase handler
Form | null$formSpecific form handler

Reimplemented in WebPortalFieldsManager.

Definition at line 128 of file fieldsmanager.class.php.

References CommonField\setForm().

Member Function Documentation

◆ clearErrors()

FieldsManager::clearErrors ( )

◆ clearFieldError()

FieldsManager::clearFieldError ( $fieldKey)

clear validation message result for a field

Parameters
string$fieldKeyKey of attribute to clear
Returns
void

Definition at line 228 of file fieldsmanager.class.php.

Referenced by verifyFieldValue(), and verifyPostFieldValue().

◆ errorsToString()

FieldsManager::errorsToString ( $separator = ',
'  )

Method to output saved errors.

Parameters
string$separatorSeparator between each error
Returns
string String with errors

Definition at line 217 of file fieldsmanager.class.php.

Referenced by printInputField(), printInputSearchField(), and printOutputField().

◆ getAllExtraFieldsInfos()

FieldsManager::getAllExtraFieldsInfos ( & $object,
& $extrafields = null,
$mode = 'view',
$params = array() )

Get list of extra fields infos.

Parameters
CommonObject$objectObject handler
ExtraFields$extrafieldsExtraFields handler
string$modeGet the fields infos for the provided mode ('create', 'edit', 'view', 'list')
array<string,mixed>$params Other params
Returns
array<string,FieldInfos> List of fields infos

Definition at line 417 of file fieldsmanager.class.php.

References $object, and getFieldInfosFromExtraField().

Referenced by getAllFieldsInfos(), and setExtraFieldValuesFromPost().

◆ getAllFields()

FieldsManager::getAllFields ( )

Get all fields handler available.

Returns
array<string,CommonField>

Definition at line 194 of file fieldsmanager.class.php.

◆ getAllFieldsInfos()

FieldsManager::getAllFieldsInfos ( & $object,
& $extrafields = null,
$mode = 'view',
$nbColumn = 2,
$breakKeys = array(),
$params = array() )

Get list of fields infos for the provided mode into X columns.

Parameters
CommonObject$objectObject handler
ExtraFields$extrafieldsExtraFields handler
string$modeGet the fields infos for the provided mode ('create', 'edit', 'view', 'list')
int$nbColumnSplit fields infos into X columns
array<int,string>$breakKeys Key used for break on each column (ex: array(1 => 'total_ht', ...))
array<string,mixed>$params Other params
Returns
array{columns:array<int,array<string,FieldInfos>>,hiddenFields:array<string,FieldInfos>} List of fields info by column and hidden

Definition at line 293 of file fieldsmanager.class.php.

References $object, dol_sort_array(), getAllExtraFieldsInfos(), getAllObjectFieldsInfos(), and getDolGlobalInt().

◆ getAllObjectFieldsInfos()

FieldsManager::getAllObjectFieldsInfos ( & $object,
$mode = 'view',
$params = array() )

Get list of object fields infos.

Parameters
CommonObject$objectObject handler
string$modeGet the fields infos for the provided mode ('create', 'edit', 'view', 'list')
array<string,mixed>$params Other params
Returns
array<string,FieldInfos> List of fields infos

Definition at line 381 of file fieldsmanager.class.php.

References $object, getDolGlobalInt(), and getFieldInfosFromObjectField().

Referenced by getAllFieldsInfos(), and setObjectFieldValuesFromPost().

◆ getFieldClass()

FieldsManager::getFieldClass ( $type)

Get field handler for the provided type.

Parameters
string$typeField type
Returns
CommonField|null

Definition at line 145 of file fieldsmanager.class.php.

References dol_include_once().

Referenced by getPostFieldValue(), getPostSearchFieldValue(), printInputField(), printInputSearchField(), printOutputField(), verifyFieldValue(), and verifyPostFieldValue().

◆ getFieldError()

FieldsManager::getFieldError ( $fieldKey)

get field error message

Parameters
string$fieldKeyKey of attribute
Returns
string Error message of validation ('' if no error)

Definition at line 257 of file fieldsmanager.class.php.

Referenced by printInputField().

◆ getFieldErrorIcon()

FieldsManager::getFieldErrorIcon ( $fieldValidationErrorMsg)

get field error icon

Parameters
string$fieldValidationErrorMsgmessage to add in tooltip
Returns
string html output

Definition at line 271 of file fieldsmanager.class.php.

References getFieldErrorIcon().

Referenced by getFieldErrorIcon(), and printInputField().

◆ getFieldInfosFromExtraField()

FieldsManager::getFieldInfosFromExtraField ( & $object,
& $extrafields,
$key,
$mode = 'view',
$params = array() )

Get field infos from extra field infos.

Parameters
CommonObject$objectObject handler
ExtraFields$extrafieldsExtrafields handler
string$keyField key
string$modeGet the fields infos for the provided mode ('create', 'edit', 'view', 'list')
array<string,mixed>$params Other params
Returns
FieldInfos|null Properties of the field or null if not found

Definition at line 571 of file fieldsmanager.class.php.

References $object, and setCommonFieldInfos().

Referenced by getAllExtraFieldsInfos(), and getFieldsInfos().

◆ getFieldInfosFromObjectField()

FieldsManager::getFieldInfosFromObjectField ( & $object,
$key,
$mode = 'view',
$params = array() )

Get field infos from object field infos.

Parameters
CommonObject$objectObject handler
string$keyField key
string$modeGet the fields infos for the provided mode ('create', 'edit', 'view', 'list')
array<string,mixed>$params Other params
Returns
FieldInfos|null Properties of the field or null if field not found

Definition at line 482 of file fieldsmanager.class.php.

References $object, and setCommonFieldInfos().

Referenced by getAllObjectFieldsInfos(), and getFieldsInfos().

◆ getFieldsInfos()

FieldsManager::getFieldsInfos ( $key,
& $object,
& $extrafields = null,
$mode = 'view',
$params = array() )

Get list of fields infos for the provided mode into X columns.

Parameters
string$keyField key (begin by object_ for object or options_ for extrafields)
CommonObject$objectObject handler
ExtraFields$extrafieldsExtraFields handler
string$modeGet the fields infos for the provided mode ('create', 'edit', 'view', 'list')
array<string,mixed>$params Other params
Returns
FieldInfos|null Get field info or null if not found

Definition at line 456 of file fieldsmanager.class.php.

References $object, getDolGlobalInt(), getFieldInfosFromExtraField(), and getFieldInfosFromObjectField().

◆ getPostFieldValue()

FieldsManager::getPostFieldValue ( $fieldInfos,
$key,
$defaultValue = null,
$keyPrefix = '',
$keySuffix = '' )

Get field value from GET/POST.

Parameters
FieldInfos$fieldInfosProperties of the field
string$keyKey of field
mixed$defaultValuePreselected value to show (for date type it must be in timestamp format, for amount or price it must be a php numeric value, for array type must be array)
string$keyPrefixPrefix string to add into name and id of field (can be used to avoid duplicate names)
string$keySuffixSuffix string to add into name and id of field (can be used to avoid duplicate names)
Returns
mixed

Definition at line 949 of file fieldsmanager.class.php.

References clearErrors(), and getFieldClass().

Referenced by setExtraFieldValuesFromPost(), and setObjectFieldValuesFromPost().

◆ getPostSearchFieldValue()

FieldsManager::getPostSearchFieldValue ( $fieldInfos,
$key,
$defaultValue = null,
$keyPrefix = '',
$keySuffix = '' )

Get search field value from GET/POST.

Parameters
FieldInfos$fieldInfosProperties of the field
string$keyKey of field
mixed$defaultValuePreselected value to show (for date type it must be in timestamp format, for amount or price it must be a php numeric value, for array type must be array)
string$keyPrefixPrefix string to add into name and id of field (can be used to avoid duplicate names)
string$keySuffixSuffix string to add into name and id of field (can be used to avoid duplicate names)
Returns
mixed

Definition at line 988 of file fieldsmanager.class.php.

References clearErrors(), and getFieldClass().

◆ printInputField()

FieldsManager::printInputField ( $fieldInfos,
$key,
$value,
$keyPrefix = '',
$keySuffix = '',
$moreCss = '',
$moreAttrib = '',
$noNewButton = 0 )

Return HTML string to put an input field into a page.

Parameters
FieldInfos$fieldInfosProperties of the field
string$keyKey of attribute
mixed$valuePreselected value to show (for date type it must be in timestamp format, for amount or price it must be a php numeric value, for array type must be array)
string$keyPrefixPrefix string to add into name and id of field (can be used to avoid duplicate names)
string$keySuffixSuffix string to add into name and id of field (can be used to avoid duplicate names)
string$moreCssValue for css to define style/length of field.
string$moreAttribTo add more attributes on html input tag
int<0,1>$noNewButton Force to not show the new button on field that are links to object
Returns
string

Definition at line 1090 of file fieldsmanager.class.php.

References clearErrors(), errorsToString(), getFieldClass(), getFieldError(), getFieldErrorIcon(), and printOutputField().

◆ printInputSearchField()

FieldsManager::printInputSearchField ( $fieldInfos,
$key,
$value,
$keyPrefix = '',
$keySuffix = '',
$moreCss = '',
$moreAttrib = '',
$noNewButton = 0 )

Return HTML string to put an input search field into a page.

Parameters
FieldInfos$fieldInfosProperties of the field
string$keyKey of attribute
mixed$valuePreselected value to show (for date type it must be in timestamp format, for amount or price it must be a php numeric value, for array type must be array)
string$keyPrefixPrefix string to add into name and id of field (can be used to avoid duplicate names)
string$keySuffixSuffix string to add into name and id of field (can be used to avoid duplicate names)
string$moreCssValue for css to define style/length of field.
string$moreAttribTo add more attributes on html input tag
int<0,1>$noNewButton Force to not show the new button on field that are links to object
Returns
string

Definition at line 1030 of file fieldsmanager.class.php.

References clearErrors(), errorsToString(), and getFieldClass().

◆ printOutputField()

FieldsManager::printOutputField ( $fieldInfos,
$key,
$value,
$keyPrefix = '',
$keySuffix = '',
$moreCss = '',
$moreAttrib = '' )

Return HTML string to show a field into a page.

Parameters
FieldInfos$fieldInfosProperties of the field
string$keyKey of attribute
mixed$valuePreselected value to show (for date type it must be in timestamp format, for amount or price it must be a php numeric value, for array type must be array)
string$keyPrefixPrefix string to add into name and id of field (can be used to avoid duplicate names)
string$keySuffixSuffix string to add into name and id of field (can be used to avoid duplicate names)
string$moreCssValue for css to define style/length of field.
string$moreAttribTo add more attributes on html input tag
Returns
string

Definition at line 1168 of file fieldsmanager.class.php.

References clearErrors(), errorsToString(), and getFieldClass().

Referenced by printInputField().

◆ printSeparator()

FieldsManager::printSeparator ( $key,
& $object,
$colspan = 2,
$display_type = 'card',
$mode = 'view' )

Return HTML string to print separator field.

Parameters
string$keyKey of attribute
object$objectObject
int$colspanValue of colspan to use (it must include the first column with title)
string$display_type"card" for form display, "line" for document line display
string$modeShow output ('view') or input ('create' or 'edit') for field
Returns
string HTML code with line for separator

Definition at line 1220 of file fieldsmanager.class.php.

◆ setCommonFieldInfos()

FieldsManager::setCommonFieldInfos ( & $fieldInfos,
& $object,
& $extrafields,
$key,
$mode = 'view',
$enabled = '1',
$visibility = '',
$perms = null,
$params = array() )

Set common field infos.

Parameters
FieldInfos$fieldInfosField infos to set with common infos
CommonObject$objectObject handler
ExtraFields$extrafieldsExtrafields handler
string$keyField key
string$modeGet the fields infos for the provided mode ('create', 'edit', 'view', 'list')
string$enabledCondition when the field must be managed (Example: 1 or 'getDolGlobalInt("MY_SETUP_PARAM")' or 'isModEnabled("multicurrency")' ...)
string$visibilityCondition when the field must be visible (Examples: 0=Not visible, 1=Visible on list and create/update/view forms, 2=Visible on list only, 3=Visible on create/update/view form only (not list), 4=Visible on list and update/view form (not create). 5=Visible on list and view form (not create/not update). 6=visible on list and update/view form (not create). Using a negative value means field is not shown by default on list but can be selected for viewing)
string$permsCondition when the field must be editable
array<string,mixed>$params Other params
Returns
void

Definition at line 643 of file fieldsmanager.class.php.

References $object, dol_eval(), and getDolGlobalString().

Referenced by getFieldInfosFromExtraField(), and getFieldInfosFromObjectField().

◆ setExtraFieldValuesFromPost()

FieldsManager::setExtraFieldValuesFromPost ( & $object,
& $extrafields,
$keyPrefix = '',
$keySuffix = '',
$mode = 'view',
$params = array() )

Set all extra field values of the object from POST.

Parameters
CommonObject$objectObject handler
ExtraFields$extrafieldsExtrafields handler
string$keyPrefixPrefix string to add into name and id of field (can be used to avoid duplicate names)
string$keySuffixSuffix string to add into name and id of field (can be used to avoid duplicate names)
string$modeGet the fields infos for the provided mode ('create', 'edit', 'view', 'list')
array<string,mixed>$params Other params
Returns
int Result <0 if KO, >0 if OK

Definition at line 834 of file fieldsmanager.class.php.

References $object, getAllExtraFieldsInfos(), getPostFieldValue(), verifyFieldValue(), and verifyPostFieldValue().

Referenced by setFieldValuesFromPost().

◆ setFieldError()

FieldsManager::setFieldError ( $fieldKey,
$msg = '' )

set validation error message a field

Parameters
string$fieldKeyKey of attribute
string$msgthe field error message
Returns
void

Definition at line 241 of file fieldsmanager.class.php.

Referenced by verifyFieldValue(), and verifyPostFieldValue().

◆ setFieldValuesFromPost()

FieldsManager::setFieldValuesFromPost ( & $object,
& $extrafields,
$keyPrefix = '',
$keySuffix = '',
$mode = 'view',
$params = array() )

Set all values of the object (with extra field) from POST.

Parameters
CommonObject$objectObject handler
ExtraFields$extrafieldsExtrafields handler
string$keyPrefixPrefix string to add into name and id of field (can be used to avoid duplicate names)
string$keySuffixSuffix string to add into name and id of field (can be used to avoid duplicate names)
string$modeGet the fields infos for the provided mode ('create', 'edit', 'view', 'list')
array<string,mixed>$params Other params
Returns
int Result <0 if KO, >0 if OK

Definition at line 780 of file fieldsmanager.class.php.

References $object, setExtraFieldValuesFromPost(), and setObjectFieldValuesFromPost().

◆ setObjectFieldValuesFromPost()

FieldsManager::setObjectFieldValuesFromPost ( & $object,
$keyPrefix = '',
$keySuffix = '',
$mode = 'view',
$params = array() )

Set all object values of the object from POST.

Parameters
CommonObject$objectObject handler
string$keyPrefixPrefix string to add into name and id of field (can be used to avoid duplicate names)
string$keySuffixSuffix string to add into name and id of field (can be used to avoid duplicate names)
string$modeGet the fields infos for the provided mode ('create', 'edit', 'view', 'list')
array<string,mixed>$params Other params
Returns
int Result <0 if KO, >0 if OK

Definition at line 798 of file fieldsmanager.class.php.

References $object, getAllObjectFieldsInfos(), getPostFieldValue(), verifyFieldValue(), and verifyPostFieldValue().

Referenced by setFieldValuesFromPost().

◆ verifyFieldValue()

FieldsManager::verifyFieldValue ( $fieldInfos,
$key,
$value )

Verify if the field value is valid.

Parameters
FieldInfos$fieldInfosProperties of the field
string$keyKey of field
mixed$valueValue to check (for date type it must be in timestamp format, for amount or price it must be a php numeric value, for array type must be array)
Returns
bool

Definition at line 908 of file fieldsmanager.class.php.

References clearErrors(), clearFieldError(), getDolGlobalInt(), getDolGlobalString(), getFieldClass(), and setFieldError().

Referenced by setExtraFieldValuesFromPost(), and setObjectFieldValuesFromPost().

◆ verifyPostFieldValue()

FieldsManager::verifyPostFieldValue ( $fieldInfos,
$key,
$keyPrefix = '',
$keySuffix = '' )

Verify if the field value is valid.

Parameters
FieldInfos$fieldInfosProperties of the field
string$keyKey of attribute
string$keyPrefixPrefix string to add into name and id of field (can be used to avoid duplicate names)
string$keySuffixSuffix string to add into name and id of field (can be used to avoid duplicate names)
Returns
bool

Definition at line 868 of file fieldsmanager.class.php.

References clearErrors(), clearFieldError(), getDolGlobalInt(), getDolGlobalString(), getFieldClass(), and setFieldError().

Referenced by setExtraFieldValuesFromPost(), and setObjectFieldValuesFromPost().


The documentation for this class was generated from the following file: