in src-js/src/document.ts [315:346]
constructor(keyBlock: ApiKeyValueSetBlock, parentForm: Form) {
this._parentForm = parentForm;
this._value = null;
this._key = new FieldKey(keyBlock, this);
let valueBlockIds: string[] = [];
(keyBlock.Relationships || []).forEach((rs) => {
if (rs.Type == ApiRelationshipType.Value) {
valueBlockIds = valueBlockIds.concat(rs.Ids);
}
});
if (valueBlockIds.length > 1) {
const fieldLogName = this._key ? `field '${this._key.text}'` : "unnamed form field";
console.warn(
`Got ${valueBlockIds.length} value blocks for ${fieldLogName} (Expected 0-1). Including first only.`
);
}
if (valueBlockIds.length) {
const parentDocument = parentForm.parentPage.parentDocument;
const valBlockId = valueBlockIds[0];
const valBlock = parentDocument.getBlockById(valBlockId);
if (!valBlock) {
console.warn(
`Document missing child block ${valBlockId} referenced by value for field key ${this.key.id}`
);
} else {
this._value = new FieldValue(valBlock as ApiKeyValueSetBlock, this);
}
}
}