forked from Wavyzz/dolibarr
Merge branch '22.0' of git@github.com:Dolibarr/dolibarr.git into develop
This commit is contained in:
@@ -1127,14 +1127,14 @@ class ExtraFields
|
||||
* Code very similar with showInputField of common object
|
||||
*
|
||||
* @param string $key Key of attribute
|
||||
* @param string|array{start:int,end:int} $value Preselected value to show (for date type it must be in timestamp format, for amount or price it must be a php numeric value); for dates in filter mode, a range array('start'=><timestamp>, 'end'=><timestamp>) should be provided
|
||||
* @param string|array{start:int,end:int} $value Preselected value to show (for date type it must be in timestamp format, for amount or price it must be a php numeric value); for dates in filter mode, a range array('start'=><timestamp>, 'end'=><timestamp>) should be provided
|
||||
* @param string $moreparam To add more parameters on html input tag
|
||||
* @param string $keysuffix Suffix string to add after name and id of field (can be used to avoid duplicate names)
|
||||
* @param string $keyprefix Prefix string to add before name and id of field (can be used to avoid duplicate names)
|
||||
* @param string $morecss More css (to defined size of field. Old behaviour: may also be a numeric)
|
||||
* @param int|CommonObject $object Current object or object ID. Preferably, pass the object itself.
|
||||
* @param string $extrafieldsobjectkey The key to use to store retrieved data (commonly $object->table_element)
|
||||
* @param int $mode 1=Used for search filters
|
||||
* @param int $mode 1=Used for search filters
|
||||
* @return string
|
||||
*/
|
||||
public function showInputField($key, $value, $moreparam = '', $keysuffix = '', $keyprefix = '', $morecss = '', $object = 0, $extrafieldsobjectkey = '', $mode = 0)
|
||||
@@ -1446,6 +1446,7 @@ class ExtraFields
|
||||
}
|
||||
}
|
||||
if (!getDolGlobalString('MAIN_EXTRAFIELDS_ENABLE_NEW_SELECT2')) {
|
||||
//$out .= '<!-- type = sellist -->';
|
||||
$out .= '<select class="flat '.$morecss.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" '.($moreparam ? $moreparam : '').'>';
|
||||
if (is_array($param['options'])) {
|
||||
// WARNING!! @FIXME This code is duplicated into core/class/extrafields.class.php
|
||||
@@ -1625,16 +1626,22 @@ class ExtraFields
|
||||
$labeltoshow = '';
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
|
||||
// Several field into label (eq table:code|label:rowid)
|
||||
$nameFields = $InfoFieldList[1];
|
||||
// If text is "field1|f(a,b,c) as xxx|field2", we must convert string into 'field1|xxx|field2'
|
||||
$nameFields = preg_replace('/[a-z_]+\([^\)]*\) as ([\w]+)/i', '\1', $nameFields);
|
||||
// Sanitize field names to avoid error when doing $obj->field
|
||||
$nameFields = preg_replace('/[^0-9a-z_\.\|]/i', '', $nameFields);
|
||||
|
||||
// Several fields into label (eq table:code|label:rowid)
|
||||
$notrans = false;
|
||||
$fields_label = explode('|', $InfoFieldList[1]);
|
||||
$fields_label = explode('|', $nameFields);
|
||||
if (is_array($fields_label) && count($fields_label) > 1) {
|
||||
$notrans = true;
|
||||
foreach ($fields_label as $field_toshow) {
|
||||
$labeltoshow .= $obj->$field_toshow.' ';
|
||||
}
|
||||
} else {
|
||||
$labeltoshow = $obj->{$InfoFieldList[1]};
|
||||
$labeltoshow = $obj->$nameFields;
|
||||
}
|
||||
|
||||
if ($value == $obj->rowid) {
|
||||
@@ -1647,7 +1654,7 @@ class ExtraFields
|
||||
$out .= '<option value="'.$obj->rowid.'" selected>'.$labeltoshow.'</option>';
|
||||
} else {
|
||||
if (!$notrans) {
|
||||
$translabel = $langs->trans($obj->{$InfoFieldList[1]});
|
||||
$translabel = $langs->trans($obj->$nameFields);
|
||||
$labeltoshow = $translabel;
|
||||
}
|
||||
if (empty($labeltoshow)) {
|
||||
@@ -1655,6 +1662,8 @@ class ExtraFields
|
||||
}
|
||||
|
||||
if (!empty($InfoFieldList[3]) && $parentField) {
|
||||
// Sanitize parent field name to avoid when doing $obj->field
|
||||
$parentField = preg_replace('/[^a-zA-Z0-9_\-]/', '', $parentField);
|
||||
$parent = $parentName.':'.$obj->{$parentField};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user