Merge pull request #8041 from timvandermeij/radio-button-value
Interactive forms: set the `buttonValue` for radio buttons that do not have a `fieldValue`
This commit is contained in:
commit
35102c025a
@ -786,14 +786,12 @@ var ButtonWidgetAnnotation = (function ButtonWidgetAnnotationClosure() {
|
||||
// The parent field's `V` entry holds a `Name` object with the appearance
|
||||
// state of whichever child field is currently in the "on" state.
|
||||
var fieldParent = params.dict.get('Parent');
|
||||
if (!isDict(fieldParent) || !fieldParent.has('V')) {
|
||||
return;
|
||||
if (isDict(fieldParent) && fieldParent.has('V')) {
|
||||
var fieldParentValue = fieldParent.get('V');
|
||||
if (isName(fieldParentValue)) {
|
||||
this.data.fieldValue = fieldParentValue.name;
|
||||
}
|
||||
}
|
||||
var fieldParentValue = fieldParent.get('V');
|
||||
if (!isName(fieldParentValue)) {
|
||||
return;
|
||||
}
|
||||
this.data.fieldValue = fieldParentValue.name;
|
||||
|
||||
// The button's value corresponds to its appearance state.
|
||||
var appearanceStates = params.dict.get('AP');
|
||||
|
@ -988,7 +988,7 @@ describe('annotation', function() {
|
||||
expect(data.radioButton).toEqual(false);
|
||||
});
|
||||
|
||||
it('should handle radio buttons', function() {
|
||||
it('should handle radio buttons with a field value', function() {
|
||||
var parentDict = new Dict();
|
||||
parentDict.set('V', Name.get('1'));
|
||||
|
||||
@ -1017,6 +1017,32 @@ describe('annotation', function() {
|
||||
expect(data.fieldValue).toEqual('1');
|
||||
expect(data.buttonValue).toEqual('2');
|
||||
});
|
||||
|
||||
it('should handle radio buttons without a field value', function() {
|
||||
var normalAppearanceStateDict = new Dict();
|
||||
normalAppearanceStateDict.set('2', null);
|
||||
|
||||
var appearanceStatesDict = new Dict();
|
||||
appearanceStatesDict.set('N', normalAppearanceStateDict);
|
||||
|
||||
buttonWidgetDict.set('Ff', AnnotationFieldFlag.RADIO);
|
||||
buttonWidgetDict.set('AP', appearanceStatesDict);
|
||||
|
||||
var buttonWidgetRef = new Ref(124, 0);
|
||||
var xref = new XRefMock([
|
||||
{ ref: buttonWidgetRef, data: buttonWidgetDict, }
|
||||
]);
|
||||
|
||||
var annotation = annotationFactory.create(xref, buttonWidgetRef,
|
||||
pdfManagerMock, idFactoryMock);
|
||||
var data = annotation.data;
|
||||
expect(data.annotationType).toEqual(AnnotationType.WIDGET);
|
||||
|
||||
expect(data.checkBox).toEqual(false);
|
||||
expect(data.radioButton).toEqual(true);
|
||||
expect(data.fieldValue).toEqual(null);
|
||||
expect(data.buttonValue).toEqual('2');
|
||||
});
|
||||
});
|
||||
|
||||
describe('ChoiceWidgetAnnotation', function() {
|
||||
|
Loading…
Reference in New Issue
Block a user