WebViewer Version:
Do you have an issue with a specific file(s)? NO
Can you reproduce using one of our samples or online demos? NO
Are you using the WebViewer server? NO
Does the issue only happen on certain browsers? NO
Is your issue related to a front-end framework? YES
Is your issue related to annotations? YES
Hi,
I’m encountering a bug when dynamically creating radio buttons in WebViewer. I’m using the Core.Annotations.RadioButtonWidgetAnnotation
to add individual radio buttons to the page. The radio buttons visually appear correctly and are grouped properly under a shared Forms.Field
, but all radio buttons in the same group end up having the same value or export value (“Yes”).
As a result, when I try to set one radio button to selected/true, all radio buttons in the group become selected, instead of just one — effectively breaking the mutual exclusivity expected from radio buttons.
I’ve included a code snippet below to show how I’m generating each radio button:
addFieldWidgetOnDocument(
page: number,
field: FieldResponse,
fieldPos: FieldPosition,
index: number,
index2: number,
): Core.Annotations.SignatureWidgetAnnotation | Core.Annotations.CheckButtonWidgetAnnotation | Core.Annotations.RadioButtonWidgetAnnotation | Core.Annotations.TextWidgetAnnotation | null {
if (!field) {
return null;
}
const pageHeight = this.instance!.Core.documentViewer.getPageHeight(page);
const pageWidth = this.instance!.Core.documentViewer.getPageWidth(page);
// mi vengono passate le posizioni in percentuale, trovo i punti in px
const height = (fieldPos.height! / 100) * pageHeight;
const width = (fieldPos.width! / 100) * pageWidth;
const left = (fieldPos.left! / 100) * pageWidth;
const top = (fieldPos.top! / 100) * pageHeight;
const suffixField = '_' + page + '_' + index;
if (field.type === FieldType.RadioGroup) {
const flags = new this.instance!.Core.Annotations.WidgetFlags();
flags.set(this.instance!.Core.Annotations.WidgetFlags.READ_ONLY, false);
flags.set(this.instance!.Core.Annotations.WidgetFlags.RADIO, false);
flags.set(this.instance!.Core.Annotations.WidgetFlags.PUSH_BUTTON, false);
const field = new this.instance!.Core.Annotations.Forms.Field('radioButtonField' + suffixField, {
type: 'Btn',
flags: flags,
});
const radioButtonWidget = new this.instance!.Core.Annotations.RadioButtonWidgetAnnotation(field, {});
radioButtonWidget.setHeight(height);
radioButtonWidget.setWidth(width);
radioButtonWidget.setX(left);
radioButtonWidget.setY(top);
radioButtonWidget.setPageNumber(page);
radioButtonWidget.Id = 'radioButtonField' + suffixField + '_' + index2;
this.instance!.Core.annotationManager.getFieldManager().addField(field);
return radioButtonWidget;
}
I also tried setting radioButtonWidget.appearance = 'option' + index2
, but it didn’t resolve the issue.
It seems like each radio button in the group is not being assigned a unique value or export value. Could you please advise on how to correctly assign distinct values to each radio button so that selecting one will unselect the others in the same group?
I’ve attached a screenshot to further illustrate the problem.
Thanks for your support!
Best regards,
William