If customfields has a label and only 1 field, use the label for the widget

This lets us use " " as label to hide the custom field's label
This commit is contained in:
nathan 2023-06-29 10:52:20 -06:00
parent 649b0bfd59
commit 85cc2a33cd

View File

@ -276,9 +276,10 @@ export class et2_customfields_list extends et2_valueWidget implements et2_IDetac
else
{
// Label in first column, widget in 2nd
const label = this.options.label || field.label;
jQuery(document.createElement("td"))
.prependTo(row);
et2_createWidget("label",{id: id + "_label", value: field.label,for: id},this);
et2_createWidget("label", {id: id + "_label", value: label.trim(), for: id}, this);
}
const type = attrs.type ? attrs.type : field.type;
@ -420,7 +421,7 @@ export class et2_customfields_list extends et2_valueWidget implements et2_IDetac
}
}
loadFromXML( _node)
loadFromXML(_node)
{
this.loadFields();
@ -428,6 +429,17 @@ export class et2_customfields_list extends et2_valueWidget implements et2_IDetac
super.loadFromXML(_node);
}
set_label(_value : string)
{
// If we've got a field list, or all fields use normal label
if(this.getType() == 'customfields-list' || jQuery.isEmptyObject(this.options.fields) ||
Object.keys(this.options.fields).filter(f => this.options.fields[f]).length != 1)
{
return super.set_label(_value);
}
// For single field, we apply the widget label to the single field
}
set_value( _value)
{
if(!this.options.customfields) return;