This commit is contained in:
philippe grand 2015-10-08 09:12:36 +02:00
commit 6cce2860c2
4 changed files with 41 additions and 14 deletions

View File

@ -678,7 +678,16 @@ if ($rowid > 0)
print '<br><br><table class="border" width="100%">'; print '<br><br><table class="border" width="100%">';
foreach($extrafields->attribute_label as $key=>$label) foreach($extrafields->attribute_label as $key=>$label)
{ {
$value=(isset($_POST["options_".$key])?$_POST["options_".$key]:(isset($adht->array_options['options_'.$key])?$adht->array_options['options_'.$key]:'')); if (isset($_POST["options_" . $key])) {
if (is_array($_POST["options_" . $key])) {
// $_POST["options"] is an array but following code expects a comma separated string
$value = implode(",", $_POST["options_" . $key]);
} else {
$value = $_POST["options_" . $key];
}
} else {
$value = $adht->array_options["options_" . $key];
}
print '<tr><td width="30%">'.$label.'</td><td>'; print '<tr><td width="30%">'.$label.'</td><td>';
print $extrafields->showInputField($key,$value); print $extrafields->showInputField($key,$value);
print "</td></tr>\n"; print "</td></tr>\n";

View File

@ -1202,7 +1202,16 @@ if ($id > 0)
print '<br><br><table class="border" width="100%">'; print '<br><br><table class="border" width="100%">';
foreach($extrafields->attribute_label as $key=>$label) foreach($extrafields->attribute_label as $key=>$label)
{ {
$value=(isset($_POST["options_".$key])?$_POST["options_".$key]:(isset($object->array_options['options_'.$key])?$object->array_options['options_'.$key]:'')); if (isset($_POST["options_" . $key])) {
if (is_array($_POST["options_" . $key])) {
// $_POST["options"] is an array but following code expects a comma separated string
$value = implode(",", $_POST["options_" . $key]);
} else {
$value = $_POST["options_" . $key];
}
} else {
$value = $object->array_options["options_" . $key];
}
print '<tr><td width="30%">'.$label.'</td><td>'; print '<tr><td width="30%">'.$label.'</td><td>';
print $extrafields->showOutputField($key,$value); print $extrafields->showOutputField($key,$value);
print "</td></tr>\n"; print "</td></tr>\n";

View File

@ -3567,9 +3567,9 @@ abstract class CommonObject
/** /**
* Function to show lines of extrafields with output datas * Function to show lines of extrafields with output datas
* *
* @param object $extrafields Extrafield Object * @param Extrafields $extrafields Extrafield Object
* @param string $mode Show output (view) or input (edit) for extrafield * @param string $mode Show output (view) or input (edit) for extrafield
* @param array $params Optionnal parameters * @param array $params Optional parameters
* @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)
* *
* @return string * @return string
@ -3601,7 +3601,16 @@ abstract class CommonObject
$value=$this->array_options["options_".$key]; $value=$this->array_options["options_".$key];
break; break;
case "edit": case "edit":
$value=(isset($_POST["options_".$key])?$_POST["options_".$key]:$this->array_options["options_".$key]); if (isset($_POST["options_" . $key])) {
if (is_array($_POST["options_" . $key])) {
// $_POST["options"] is an array but following code expects a comma separated string
$value = implode(",", $_POST["options_" . $key]);
} else {
$value = $_POST["options_" . $key];
}
} else {
$value = $this->array_options["options_" . $key];
}
break; break;
} }
if ($extrafields->attribute_type[$key] == 'separate') if ($extrafields->attribute_type[$key] == 'separate')

View File

@ -1155,7 +1155,7 @@ class ExtraFields
else if (in_array($key_type,array('checkbox'))) else if (in_array($key_type,array('checkbox')))
{ {
$value_arr=GETPOST("options_".$key.$keyprefix); $value_arr=GETPOST("options_".$key.$keyprefix);
$value_key=implode($value_arr,','); $value_key=implode(',', $value_arr);
} }
else if (in_array($key_type,array('price','double'))) else if (in_array($key_type,array('price','double')))
{ {