dolibarr 23.0.3
CommonField Class Reference

Class to common field. More...

Inheritance diagram for CommonField:
Collaboration diagram for CommonField:

Public Member Functions

 __construct ($db)
 Constructor.
 
 clearErrors ()
 clear errors
 
 errorsToString ($separator=', ')
 Method to output saved errors.
 
 isEmptyValue ($fieldInfos, $value, $emptyValues=null)
 Check if the value is deemed as empty.
 
 printInputSearchField ($fieldInfos, $key, $value, $keyPrefix='', $keySuffix='', $moreCss='', $moreAttrib='')
 Return HTML string to put an input search field into a page.
 
 printInputField ($fieldInfos, $key, $value, $keyPrefix='', $keySuffix='', $moreCss='', $moreAttrib='')
 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.
 
 getInputCss ($fieldInfos, $moreCss='', $defaultCss='minwidth400')
 Get input CSS.
 
 verifyFieldValue ($fieldInfos, $key, $value)
 Verify if the field value is valid.
 
 verifyPostFieldValue ($fieldInfos, $key, $keyPrefix='', $keySuffix='')
 Verify if the field value from GET/POST 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.
 
 sqlFilterSearchField ($fieldInfos, $key, $value)
 Get sql filter for search field.
 

Static Public Member Functions

static setForm (&$form)
 Set form used for print the field.
 
static setValidator (&$validator)
 Set validator used for check the field value.
 

Detailed Description

Class to common field.

Definition at line 31 of file commonfield.class.php.

Constructor & Destructor Documentation

◆ __construct()

CommonField::__construct ( $db)

Constructor.

Parameters
DoliDB$dbDatabase handler

Definition at line 79 of file commonfield.class.php.

References setForm(), setValidator(), and type.

Member Function Documentation

◆ clearErrors()

CommonField::clearErrors ( )

clear errors

Returns
void

Definition at line 132 of file commonfield.class.php.

◆ errorsToString()

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

Method to output saved errors.

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

Definition at line 144 of file commonfield.class.php.

◆ getInputCss()

CommonField::getInputCss ( $fieldInfos,
$moreCss = '',
$defaultCss = 'minwidth400' )

Get input CSS.

Parameters
FieldInfos$fieldInfosProperties of the field
string$moreCssValue for css to define style/length of field.
string$defaultCssDefault value for css to define style/length of field.
Returns
string
See also
self\printInputSearchField(), self\printInputField()

Reimplemented in BooleanField, CheckboxField, ChkbxlstField, CommonGeoField, DateField, DatetimeField, DatetimegmtField, DoubleField, DurationField, EmailField, HtmlField, IconField, IntField, IpField, LinkField, PasswordField, PhoneField, PricecyField, PriceField, RadioField, RealField, SelectField, SellistField, StarsField, TextField, TimestampField, UrlField, and VarcharField.

Definition at line 236 of file commonfield.class.php.

◆ getPostFieldValue()

CommonField::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
See also
self\printInputField()

Reimplemented in BooleanField, CheckboxField, ChkbxlstField, CommonGeoField, DateField, DatetimeField, DatetimegmtField, DoubleField, DurationField, EmailField, HtmlField, IconField, IntField, IpField, LinkField, PasswordField, PhoneField, PricecyField, PriceField, RadioField, RealField, SelectField, SellistField, StarsField, TextField, TimestampField, UrlField, and VarcharField.

Definition at line 337 of file commonfield.class.php.

◆ getPostSearchFieldValue()

CommonField::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
See also
self\printInputSearchField()

Reimplemented in BooleanField, CheckboxField, ChkbxlstField, CommonGeoField, DateField, DatetimeField, DatetimegmtField, DoubleField, DurationField, EmailField, HtmlField, IconField, IntField, IpField, LinkField, PasswordField, PhoneField, PricecyField, PriceField, RadioField, RealField, SelectField, SellistField, StarsField, TextField, TimestampField, UrlField, and VarcharField.

Definition at line 353 of file commonfield.class.php.

◆ isEmptyValue()

CommonField::isEmptyValue ( $fieldInfos,
$value,
$emptyValues = null )

Check if the value is deemed as empty.

Parameters
FieldInfos$fieldInfosProperties of the 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)
array<int,mixed>$emptyValues List of value deemed as empty
Returns
bool

Definition at line 157 of file commonfield.class.php.

Referenced by SelectField\getPostFieldValue(), PricecyField\getPriceAndCurrencyFromValue(), CheckboxField\printInputField(), ChkbxlstField\printInputField(), DateField\printInputField(), DatetimeField\printInputField(), DatetimegmtField\printInputField(), DoubleField\printInputField(), LinkField\printInputField(), PricecyField\printInputField(), PriceField\printInputField(), RadioField\printInputField(), RealField\printInputField(), SelectField\printInputField(), SellistField\printInputField(), TimestampField\printInputField(), ChkbxlstField\printInputSearchField(), RadioField\printInputSearchField(), SelectField\printInputSearchField(), CheckboxField\printOutputField(), ChkbxlstField\printOutputField(), CommonGeoField\printOutputField(), DateField\printOutputField(), DatetimeField\printOutputField(), DatetimegmtField\printOutputField(), DoubleField\printOutputField(), DurationField\printOutputField(), EmailField\printOutputField(), HtmlField\printOutputField(), IconField\printOutputField(), IntField\printOutputField(), IpField\printOutputField(), PasswordField\printOutputField(), PhoneField\printOutputField(), PricecyField\printOutputField(), PriceField\printOutputField(), RealField\printOutputField(), SelectField\printOutputField(), SellistField\printOutputField(), TextField\printOutputField(), TimestampField\printOutputField(), UrlField\printOutputField(), VarcharField\printOutputField(), BooleanField\sqlFilterSearchField(), CheckboxField\sqlFilterSearchField(), DateField\sqlFilterSearchField(), DatetimeField\sqlFilterSearchField(), DatetimegmtField\sqlFilterSearchField(), DoubleField\sqlFilterSearchField(), DurationField\sqlFilterSearchField(), EmailField\sqlFilterSearchField(), HtmlField\sqlFilterSearchField(), IconField\sqlFilterSearchField(), IntField\sqlFilterSearchField(), IpField\sqlFilterSearchField(), LinkField\sqlFilterSearchField(), PasswordField\sqlFilterSearchField(), PhoneField\sqlFilterSearchField(), PriceField\sqlFilterSearchField(), RadioField\sqlFilterSearchField(), RealField\sqlFilterSearchField(), SelectField\sqlFilterSearchField(), StarsField\sqlFilterSearchField(), TextField\sqlFilterSearchField(), TimestampField\sqlFilterSearchField(), UrlField\sqlFilterSearchField(), VarcharField\sqlFilterSearchField(), BooleanField\verifyFieldValue(), CheckboxField\verifyFieldValue(), ChkbxlstField\verifyFieldValue(), verifyFieldValue(), DateField\verifyFieldValue(), DatetimeField\verifyFieldValue(), DatetimegmtField\verifyFieldValue(), DoubleField\verifyFieldValue(), DurationField\verifyFieldValue(), EmailField\verifyFieldValue(), IntField\verifyFieldValue(), IpField\verifyFieldValue(), LinkField\verifyFieldValue(), PasswordField\verifyFieldValue(), PhoneField\verifyFieldValue(), PricecyField\verifyFieldValue(), PriceField\verifyFieldValue(), RadioField\verifyFieldValue(), RealField\verifyFieldValue(), SelectField\verifyFieldValue(), SellistField\verifyFieldValue(), StarsField\verifyFieldValue(), TimestampField\verifyFieldValue(), and UrlField\verifyFieldValue().

◆ printInputField()

CommonField::printInputField ( $fieldInfos,
$key,
$value,
$keyPrefix = '',
$keySuffix = '',
$moreCss = '',
$moreAttrib = '' )

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

Parameters
FieldInfos$fieldInfosProperties of the field
string$keyKey of field
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

Reimplemented in BooleanField, CheckboxField, ChkbxlstField, CommonGeoField, DateField, DatetimeField, DatetimegmtField, DoubleField, DurationField, EmailField, HtmlField, IconField, IntField, IpField, LinkField, PasswordField, PhoneField, PricecyField, PriceField, RadioField, RealField, SelectField, SellistField, StarsField, TextField, TimestampField, UrlField, and VarcharField.

Definition at line 205 of file commonfield.class.php.

◆ printInputSearchField()

CommonField::printInputSearchField ( $fieldInfos,
$key,
$value,
$keyPrefix = '',
$keySuffix = '',
$moreCss = '',
$moreAttrib = '' )

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

Parameters
FieldInfos$fieldInfosProperties of the field
string$keyKey of field
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

Reimplemented in BooleanField, CheckboxField, ChkbxlstField, CommonGeoField, DateField, DatetimeField, DatetimegmtField, DoubleField, DurationField, EmailField, HtmlField, IconField, IntField, IpField, LinkField, PasswordField, PhoneField, PricecyField, PriceField, RadioField, RealField, SelectField, SellistField, StarsField, TextField, TimestampField, UrlField, and VarcharField.

Definition at line 188 of file commonfield.class.php.

◆ printOutputField()

CommonField::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 field
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

Reimplemented in BooleanField, CheckboxField, ChkbxlstField, CommonGeoField, DateField, DatetimeField, DatetimegmtField, DoubleField, DurationField, EmailField, HtmlField, IconField, IntField, IpField, PasswordField, PhoneField, PricecyField, PriceField, RadioField, RealField, SelectField, SellistField, StarsField, TextField, TimestampField, UrlField, and VarcharField.

Definition at line 222 of file commonfield.class.php.

◆ setForm()

static CommonField::setForm ( & $form)
static

Set form used for print the field.

Parameters
Form$formForm handler
Returns
void

Definition at line 111 of file commonfield.class.php.

Referenced by __construct(), and FieldsManager\__construct().

◆ setValidator()

static CommonField::setValidator ( & $validator)
static

Set validator used for check the field value.

Parameters
Validate$validatorValidate handler
Returns
void

Definition at line 122 of file commonfield.class.php.

Referenced by __construct().

◆ sqlFilterSearchField()

CommonField::sqlFilterSearchField ( $fieldInfos,
$key,
$value )

Get sql filter for search field.

Parameters
FieldInfos$fieldInfosProperties of the field
string$keyKey of field
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)
Returns
string
See also
self\printInputSearchField(), self\getPostSearchFieldValue()

Reimplemented in BooleanField, CheckboxField, ChkbxlstField, CommonGeoField, DateField, DatetimeField, DatetimegmtField, DoubleField, DurationField, EmailField, HtmlField, IconField, IntField, IpField, LinkField, PasswordField, PhoneField, PricecyField, PriceField, RadioField, RealField, SelectField, SellistField, StarsField, TextField, TimestampField, UrlField, and VarcharField.

Definition at line 367 of file commonfield.class.php.

◆ verifyFieldValue()

CommonField::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
See also
self\printInputField()

Reimplemented in BooleanField, CheckboxField, ChkbxlstField, CommonGeoField, DateField, DatetimeField, DatetimegmtField, DoubleField, DurationField, EmailField, HtmlField, IconField, IntField, IpField, LinkField, PasswordField, PhoneField, PricecyField, PriceField, RadioField, RealField, SelectField, SellistField, StarsField, TextField, TimestampField, UrlField, and VarcharField.

Definition at line 259 of file commonfield.class.php.

References isEmptyValue().

Referenced by verifyPostFieldValue().

◆ verifyPostFieldValue()

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

Verify if the field value from GET/POST is valid.

Parameters
FieldInfos$fieldInfosProperties of the field
string$keyKey of field
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
See also
self\printInputField()

Reimplemented in BooleanField, CheckboxField, ChkbxlstField, CommonGeoField, DateField, DatetimeField, DatetimegmtField, DoubleField, DurationField, EmailField, HtmlField, IconField, IntField, IpField, LinkField, PasswordField, PhoneField, PricecyField, PriceField, RadioField, RealField, SelectField, SellistField, StarsField, TextField, TimestampField, UrlField, and VarcharField.

Definition at line 319 of file commonfield.class.php.

References GETPOST(), and verifyFieldValue().


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