M12: a push button that must be filled in isn't marked Required

This commit is contained in:
Eric Kaden
2026-10-27 21:23:48 -04:00
parent 1404a5996e
commit 0e57602e25
3 changed files with 8 additions and 4 deletions
+3 -2
View File
@@ -174,8 +174,9 @@ impl Emitter<'_> {
ff |= 1;
}
// Required, which viewers outline when they highlight a form's fields. A radio button's
// flags are its group's: the group takes it below.
if w.required && !matches!(w.kind, WidgetKind::Radio { .. }) {
// flags are its group's: the group takes it below. A push button keeps no value (ISO
// 32000-2 §12.7.5.2.2), so there is nothing it could be required to hold.
if w.required && !matches!(w.kind, WidgetKind::Radio { .. } | WidgetKind::Button { .. }) {
ff |= 1 << 1;
}
let mut top_level = true;
+4 -1
View File
@@ -345,7 +345,8 @@ fn rendering_into_the_pdf_replaces_the_placeholder_page_and_adds_fields() {
/// Required field, which viewers outline when they highlight a form's fields: a radio group on the
/// group field, its buttons' flags being the group's (a button of its own that must be chosen
/// makes the group required too). `nullTest="warning"` only recommends a value,
/// so it, like no test, leaves the field optional.
/// so it, like no test, leaves the field optional. A push button keeps no value (ISO 32000-2
/// §12.7.5.2.2), so it is never required.
#[test]
fn fields_that_must_be_filled_in_are_required() {
let xdp = r##"<?xml version="1.0" encoding="UTF-8"?>
@@ -355,6 +356,7 @@ fn fields_that_must_be_filled_in_are_required() {
<field name="should" w="2in" h="0.3in"><ui><textEdit/></ui><validate nullTest="warning"/></field>
<field name="may" w="2in" h="0.3in"><ui><textEdit/></ui></field>
<field name="agree" w="2in" h="0.3in"><ui><checkButton/></ui><items><integer>1</integer><integer>0</integer></items><validate nullTest="error"/></field>
<field name="go" w="1in" h="0.3in"><ui><button/></ui><caption><value><text>Go</text></value></caption><validate nullTest="error"/></field>
<exclGroup name="answer" layout="lr-tb"><validate nullTest="error"/>
<field name="yes" w="1in" h="0.3in"><ui><checkButton shape="round"/></ui><items><text>Y</text></items></field>
<field name="no" w="1in" h="0.3in"><ui><checkButton shape="round"/></ui><items><text>N</text></items></field>
@@ -385,6 +387,7 @@ fn fields_that_must_be_filled_in_are_required() {
assert_eq!(leaf("should"), Some(false), "a warning only recommends a value");
assert_eq!(leaf("may"), Some(false));
assert_eq!(leaf("agree"), Some(true), "a check box too");
assert_eq!(leaf("go"), Some(false), "a push button holds no value to fill in");
assert_eq!(leaf("answer"), Some(true), "the radio group field");
assert_eq!(leaf("optional"), Some(false));
assert_eq!(leaf("second"), Some(true), "a later button that must be chosen makes its group required");
File diff suppressed because one or more lines are too long