Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/core/src/components/fields/BooleanField.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function BooleanField(props) {
rawErrors,
} = props;
const { title } = schema;
const { widgets, formContext } = registry;
const { widgets, formContext, fields } = registry;
const { widget = "checkbox", ...options } = getUiOptions(uiSchema);
const Widget = getWidget(schema, widget, widgets);

Expand Down Expand Up @@ -67,6 +67,7 @@ function BooleanField(props) {
formContext={formContext}
autofocus={autofocus}
rawErrors={rawErrors}
DescriptionField={fields.DescriptionField}
/>
);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/components/widgets/CheckboxWidget.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React from "react";
import PropTypes from "prop-types";
import DescriptionField from "../fields/DescriptionField.js";

// Check to see if a schema specifies that a value must be true
function schemaRequiresTrueValue(schema) {
Expand Down Expand Up @@ -43,6 +42,7 @@ function CheckboxWidget(props) {
onBlur,
onFocus,
onChange,
DescriptionField,
} = props;

// Because an unchecked checkbox will cause html5 validation to fail, only add
Expand Down
17 changes: 17 additions & 0 deletions packages/core/test/BooleanField_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,23 @@ describe("BooleanField", () => {
expect(description.textContent).eql("my description");
});

it("should render the description using provided description field", () => {
const { node } = createFormComponent({
schema: {
type: "boolean",
description: "my description",
},
fields: {
DescriptionField: ({ description }) => (
<div className="field-description">{description} overridden</div>
),
},
});

const description = node.querySelector(".field-description");
expect(description.textContent).eql("my description overridden");
});

it("should assign a default value", () => {
const { node } = createFormComponent({
schema: {
Expand Down