ExtraFields
class ExtraFields (View source)
Class to manage standard extra fields
Properties
| DoliDB | $db | ||
| array<string, array{label: array<string, string>, type: array<string, string>, size: array<string, string>, default: array<string, string>, computed: array<string, string>, unique: array<string, int>, required: array<string, int>, param: array<string, mixed>, perms: array<string, mixed>, list: array<string, int|string>, pos: array<string, int>, totalizable: array<string, int>, help: array<string, string>, printable: array<string, int>, enabled: array<string, int>, langfile: array<string, string>, css: array<string, string>, csslist: array<string, string>, cssview: array<string, string>, hidden: array<string, int>, mandatoryfieldsofotherentities: array<string, string>, alwayseditable: array<string, int<0, 1>>, emptyonclone: array<string, int<0, 1>>, loaded?: int, count: int, aiprompt: array<string, string>}> | $attributes | ||
| array<string, bool|int<0, 1>>|null | $expand_display | ||
| string | $error | ||
| string[] | $errors | ||
| string | $errno | ||
| static array<string, string> | $type2label | ||
| static array<string, array<string, string>> | $geoDataTypes |
Methods
Constructor
Add a new extra field parameter
Update an existing extra field parameter
Delete an optional attribute
Modify type of a personalized attribute
Load the array of extrafields definition $this->attributes
Return HTML string to put an input field into a page Code very similar with showInputField of common object
Return HTML string to put an output field into a page
Return the CSS to use for this extrafield into list
Return the CSS to use for this extrafield into list
Return HTML string to print separator extrafield
Fill array_options property of object by extrafields value (using for data sent by forms)
return array_options array of data of extrafields value of object sent by a search form
Return array with all possible types and labels of extrafields
Return if a value is "empty" for a mandatory vision.
Details
__construct($db)
Constructor
@param DoliDB $db Database handler
addExtraField($attrname, string $label, $type, $pos, $size, $elementtype, $unique = 0, $required = 0, $default_value = '', $param = '', $alwayseditable = 0, $perms = '', $list = '-1', $help = '', $computed = '', $entity = '', $langfile = '', $enabled = '1', $totalizable = 0, $printable = 0, $moreparams = array(), $aiprompt = "", $emptyonclone = 0)
Add a new extra field parameter
@param string $attrname Code of attribute
updateExtraField($attrname, string $label, $type, $pos, $size, $elementtype, $unique = 0, $required = 0, $default_value = '', $param = '', $alwayseditable = 0, $perms = '', $list = '-1', $help = '', $computed = '', $entity = '', $langfile = '', $enabled = '1', $totalizable = 0, $printable = 0, $moreparams = array(), int<0, 1> $emptyonclone = 0)
Update an existing extra field parameter
@param string $attrname Code of attribute
delete(string $attrname, $elementtype = '')
Delete an optional attribute
update($attrname, string $label, $type, $length, $elementtype, $unique = 0, $required = 0, $pos = 0, $param = array(), $alwayseditable = 0, $perms = '', $list = '', $help = '', $default = '', $computed = '', $entity = '', $langfile = '', $enabled = '1', $totalizable = 0, $printable = 0, $moreparams = array(), $aiprompt = "", int<0, 1> $emptyonclone = 0)
Modify type of a personalized attribute
@param string $attrname Name of attribute
fetch_name_optionals_label($elementtype, bool $forceload = false, $attrname = '')
Load the array of extrafields definition $this->attributes
@param string $elementtype Type of element ('all' = all or $object->table_element like 'adherent', 'commande', 'thirdparty', 'facture', 'propal', 'product', ...).
string
showInputField(string $key, string|array{start: int, end: int} $value, string $moreparam = '', string $keysuffix = '', string $keyprefix = '', string $morecss = '', int|CommonObject $object = 0, string $extrafieldsobjectkey = '', int $mode = 0)
Return HTML string to put an input field into a page Code very similar with showInputField of common object
string
showOutputField(string $key, string $value, string $moreparam = '', string $extrafieldsobjectkey = '', Translate|null $outputlangs = null, CommonObject|null $object = null, string $mode = '')
Return HTML string to put an output field into a page
string
getAlignFlag(string $key, string $extrafieldsobjectkey = '')
deprecated
deprecated
Return the CSS to use for this extrafield into list
string
getCSSClass(string $key, string $extrafieldsobjectkey = '', string $mode = 'csslist')
Return the CSS to use for this extrafield into list
string
showSeparator(string $key, object $object, int $colspan = 2, string $display_type = 'card', string $mode = '')
Return HTML string to print separator extrafield
int
setOptionalsFromPost(null $extralabels, CommonObject $object, string $onlykey = '', int $todefaultifmissing = 0)
Fill array_options property of object by extrafields value (using for data sent by forms)
array<string, mixed>|int<0, 0>
getOptionalsFromPost(array<string, mixed>|string $extrafieldsobjectkey, string $keysuffix = '', string $keyprefix = '')
return array_options array of data of extrafields value of object sent by a search form
static string[]
getListOfTypesLabels()
Return array with all possible types and labels of extrafields
static bool
isEmptyValue(null|int|float|string|array<int|string, mixed> $v, string $type)
Return if a value is "empty" for a mandatory vision.