diff --git a/lib/form/html.js b/lib/form/html.js
index 5d9b700..92c23b6 100644
--- a/lib/form/html.js
+++ b/lib/form/html.js
@@ -67,6 +67,7 @@ const addRequired = (html, input, index) => {
required: input.inputs[index][inp].required,
name: `${input.id}--${inp}--${index}`,
id: input.inputs[index][inp].id,
+ type: input.inputs[index][inp].type,
});
});
}
@@ -76,11 +77,17 @@ const addRequired = (html, input, index) => {
required: input.inputs[inp].required,
name: `${input.id}--${inp}`,
id: input.inputs[inp].id,
+ type: input.inputs[inp].type,
});
});
}
inputs.map(inp => {
+ // Skip the required attribute for checkbox and radio on browser
+ if (input.type === 'checkbox' || input.type === 'radio') {
+ return;
+ }
+
if (input.required === 'save' || inp.required === 'save' || input.required === 'publish' || inp.required === 'publish') {
let level = '';
if (inp.required !== undefined) {
diff --git a/tests/html.js b/tests/html.js
index 6710545..955e8b6 100644
--- a/tests/html.js
+++ b/tests/html.js
@@ -106,3 +106,29 @@ test('Add Required - Pass', t => {
t.true(includes(result, expected));
});
+test('Add Required Checkbox - Pass', t => {
+ const param = {
+ html: '"test"',
+ input: {
+ description: 'I am the Bar Content Type Config textarea description',
+ html: '""',
+ id: 'my-checkbox',
+ inputs: {
+ checkbox: {
+ id: '91f79620-ba21-4a4a-a4c7-02f456129b0f--1',
+ label: 'My Awesome Checkbox',
+ name: 'my-checkbox--checkbox',
+ type: 'checkbox',
+ },
+ },
+ name: 'My Awesome Checkbox',
+ required: 'save',
+ type: 'checkbox',
+ },
+ index: undefined,
+ };
+ const expected = 'aria-required="true" required';
+ const result = html.required(param.html, param.input, param.index);
+ t.false(includes(result, expected));
+});
+