diff --git a/views/bootstrap/class.Bootstrap.php b/views/bootstrap/class.Bootstrap.php
index ae5228d2c..e4087d929 100644
--- a/views/bootstrap/class.Bootstrap.php
+++ b/views/bootstrap/class.Bootstrap.php
@@ -2100,6 +2100,15 @@ $(document).ready(function() {
echo self::getAttributeEditField($attrdef, $attribute, $fieldname, $norequire, $namepostfix, $alwaysmultiple);
} /* }}} */
+ /**
+ * Return html code for an input/select field of an attribute
+ *
+ * The passed attribute ($attribute) can either be an object of type
+ * SeedDMS_Core_Attribute, scalar or an array. A scalar or array is
+ * passed when the method is called to create the search form. In that
+ * case $attribute has the value from the post data after submitting the
+ * search form.
+ */
function getAttributeEditField($attrdef, $attribute, $fieldname='attributes', $norequire=false, $namepostfix='', $alwaysmultiple=false) { /* {{{ */
$dms = $this->params['dms'];
$attr_id = $fieldname.'_'.$attrdef->getId().($namepostfix ? '_'.$namepostfix : '');
@@ -2136,10 +2145,19 @@ $(document).ready(function() {
$content .= $this->getDocumentChooserHtml("attr".$attrdef->getId(), M_READ, -1, $target, $attr_name);
break;
case SeedDMS_Core_AttributeDefinition::type_user:
- $target = $attribute ? $attribute->getValueAsArray() : [];
$objvalue = [];
- foreach($target as $t)
- $objvalue[] = $t->getId();
+ if($attribute) {
+ if(is_object($attribute)) {
+ $target = $attribute->getValueAsArray();
+ foreach($target as $t)
+ $objvalue[] = $t->getId();
+ } elseif(is_array($attribute)) {
+ foreach($attribute as $t)
+ $objvalue[] = $t;
+ } else {
+ $objvalue[] = $attribute;
+ }
+ }
$users = $dms->getAllUsers();
if($users) {
$allowempty = $attrdef->getMinValues() == 0;
@@ -2159,10 +2177,19 @@ $(document).ready(function() {
}
break;
case SeedDMS_Core_AttributeDefinition::type_group:
- $target = $attribute ? $attribute->getValueAsArray() : [];
$objvalue = [];
- foreach($target as $t)
- $objvalue[] = $t->getId();
+ if($attribute) {
+ if(is_object($attribute)) {
+ $target = $attribute->getValueAsArray();
+ foreach($target as $t)
+ $objvalue[] = $t->getId();
+ } elseif(is_array($attribute)) {
+ foreach($attribute as $t)
+ $objvalue[] = $t;
+ } else {
+ $objvalue[] = $attribute;
+ }
+ }
$groups = $dms->getAllGroups();
if($groups) {
$allowempty = $attrdef->getMinValues() == 0;
diff --git a/views/bootstrap/class.DocumentVersionDetail.php b/views/bootstrap/class.DocumentVersionDetail.php
index d11d0ad94..4a15a6e57 100644
--- a/views/bootstrap/class.DocumentVersionDetail.php
+++ b/views/bootstrap/class.DocumentVersionDetail.php
@@ -353,7 +353,7 @@ class SeedDMS_View_DocumentVersionDetail extends SeedDMS_Theme_Style {
print "
".$arr[0].": ".$arr[1]."\n";
} else {
$attrdef = $attribute->getAttributeDefinition();
- print "".htmlspecialchars($attrdef->getName()).": ".htmlspecialchars(implode(', ', $attribute->getValueAsArray()))."\n";
+ print "".htmlspecialchars($attrdef->getName()).": ".htmlspecialchars($attribute->getValueAsString())."\n";
}
}
}
diff --git a/views/bootstrap/class.Search.php b/views/bootstrap/class.Search.php
index caeaa4fba..4d2e62b8c 100644
--- a/views/bootstrap/class.Search.php
+++ b/views/bootstrap/class.Search.php
@@ -813,9 +813,9 @@ $(document).ready(function() {
} elseif(in_array($attrdef->getType(), [SeedDMS_Core_AttributeDefinition::type_int, SeedDMS_Core_AttributeDefinition::type_float]) && !$attrdef->getValueSet()) {
$this->formField(htmlspecialchars($attrdef->getName().' ('.getMLText('from').')'), $this->getAttributeEditField($attrdef, !empty($attributes[$attrdef->getID()]['from']) ? $attributes[$attrdef->getID()]['from'] : '', 'attributes', true, 'from'));
$this->formField(htmlspecialchars($attrdef->getName().' ('.getMLText('to').')'), $this->getAttributeEditField($attrdef, !empty($attributes[$attrdef->getID()]['to']) ? $attributes[$attrdef->getID()]['to'] : '', 'attributes', true, 'to'));
-
- } else
- $this->formField(htmlspecialchars($attrdef->getName()), $this->getAttributeEditField($attrdef, isset($attributes[$attrdef->getID()]) ? $attributes[$attrdef->getID()] : '', 'attributes', true, '', true));
+ } else {
+ $this->formField(htmlspecialchars($attrdef->getName()), $this->getAttributeEditField($attrdef, isset($attributes[$attrdef->getID()]) ? $attributes[$attrdef->getID()] : '', 'attributes', true, '', false));
+ }
}
}
}
diff --git a/views/bootstrap4/class.Bootstrap4.php b/views/bootstrap4/class.Bootstrap4.php
index 1bdd4e5cd..c2be23b6d 100644
--- a/views/bootstrap4/class.Bootstrap4.php
+++ b/views/bootstrap4/class.Bootstrap4.php
@@ -2044,6 +2044,15 @@ $(document).ready(function() {
echo self::getAttributeEditField($attrdef, $attribute, $fieldname, $norequire, $namepostfix, $alwaysmultiple);
} /* }}} */
+ /**
+ * Return html code for an input/select field of an attribute
+ *
+ * The passed attribute ($attribute) can either be an object of type
+ * SeedDMS_Core_Attribute, scalar or an array. A scalar or array is
+ * passed when the method is called to create the search form. In that
+ * case $attribute has the value from the post data after submitting the
+ * search form.
+ */
function getAttributeEditField($attrdef, $attribute, $fieldname='attributes', $norequire=false, $namepostfix='', $alwaysmultiple=false) { /* {{{ */
$dms = $this->params['dms'];
$attr_id = $fieldname.'_'.$attrdef->getId().($namepostfix ? '_'.$namepostfix : '');
@@ -2077,18 +2086,27 @@ $(document).ready(function() {
$content .= "getMinValues() > 0) ? ' required="required"' : '')." data-rule-number=\"true\"/>";
break; */
case SeedDMS_Core_AttributeDefinition::type_folder:
- $target = $attribute ? $attribute->getValue() : null;
+ $target = $attribute ? (is_object($attribute) ? $attribute->getValue() : $attribute) : null;
$content .= $this->getFolderChooserHtml("attr".$attrdef->getId(), M_READWRITE, -1, $target, $attr_name, false);
break;
case SeedDMS_Core_AttributeDefinition::type_document:
- $target = $attribute ? $attribute->getValue() : null;
+ $target = $attribute ? (is_object($attribute) ? $attribute->getValue() : $attribute) : null;
$content .= $this->getDocumentChooserHtml("attr".$attrdef->getId(), M_READ, -1, $target, $attr_name);
break;
case SeedDMS_Core_AttributeDefinition::type_user:
- $target = $attribute ? $attribute->getValueAsArray() : [];
$objvalue = [];
- foreach($target as $t)
- $objvalue[] = $t->getId();
+ if($attribute) {
+ if(is_object($attribute)) {
+ $target = $attribute->getValueAsArray();
+ foreach($target as $t)
+ $objvalue[] = $t->getId();
+ } elseif(is_array($attribute)) {
+ foreach($attribute as $t)
+ $objvalue[] = $t;
+ } else {
+ $objvalue[] = $attribute;
+ }
+ }
$users = $dms->getAllUsers();
if($users) {
$allowempty = $attrdef->getMinValues() == 0;
@@ -2108,10 +2126,19 @@ $(document).ready(function() {
}
break;
case SeedDMS_Core_AttributeDefinition::type_group:
- $target = $attribute ? $attribute->getValueAsArray() : [];
$objvalue = [];
- foreach($target as $t)
- $objvalue[] = $t->getId();
+ if($attribute) {
+ if(is_object($attribute)) {
+ $target = $attribute->getValueAsArray();
+ foreach($target as $t)
+ $objvalue[] = $t->getId();
+ } elseif(is_array($attribute)) {
+ foreach($attribute as $t)
+ $objvalue[] = $t;
+ } else {
+ $objvalue[] = $attribute;
+ }
+ }
$groups = $dms->getAllGroups();
if($groups) {
$allowempty = $attrdef->getMinValues() == 0;