FIX Preselected value for extrafield link was not correctly set

This commit is contained in:
Laurent Destailleur 2016-12-06 13:10:44 +01:00
parent bd0b017571
commit 017e384f16
2 changed files with 15 additions and 8 deletions

View File

@ -660,7 +660,7 @@ class ExtraFields
* Return HTML string to put an input field into a page * Return HTML string to put an input field into a page
* *
* @param string $key Key of attribute * @param string $key Key of attribute
* @param string $value Value to show (for date type it must be in timestamp format) * @param string $value Preselected value to show (for date type it must be in timestamp format)
* @param string $moreparam To add more parametes on html input tag * @param string $moreparam To add more parametes on html input tag
* @param string $keyprefix Prefix string to add into name and id of field (can be used to avoid duplicate names) * @param string $keyprefix Prefix string to add into name and id of field (can be used to avoid duplicate names)
* @param string $keysuffix Suffix string to add into name and id of field (can be used to avoid duplicate names) * @param string $keysuffix Suffix string to add into name and id of field (can be used to avoid duplicate names)
@ -1162,11 +1162,18 @@ class ExtraFields
$InfoFieldList = explode(":", $param_list[0]); $InfoFieldList = explode(":", $param_list[0]);
dol_include_once($InfoFieldList[1]); dol_include_once($InfoFieldList[1]);
if ($InfoFieldList[0] && class_exists($InfoFieldList[0])) if ($InfoFieldList[0] && class_exists($InfoFieldList[0]))
{
$valuetoshow=$value;
if (!empty($value))
{ {
$object = new $InfoFieldList[0]($this->db); $object = new $InfoFieldList[0]($this->db);
if (!empty($value)) $object->fetch($value); $resfetch=$object->fetch($value);
if ($resfetch > 0)
{
$valuetoshow=$object->ref; $valuetoshow=$object->ref;
if ($object->element == 'societe') $valuetoshow=$object->name; // Special case for thirdparty because ref is id because name is not unique if ($object->element == 'societe') $valuetoshow=$object->name; // Special case for thirdparty because ->ref is not name but id (because name is not unique)
}
}
$out.='<input type="text" class="flat '.$showsize.'" name="'.$keysuffix.'options_'.$key.$keyprefix.'" value="'.$valuetoshow.'" >'; $out.='<input type="text" class="flat '.$showsize.'" name="'.$keysuffix.'options_'.$key.$keyprefix.'" value="'.$valuetoshow.'" >';
} }
else else