Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show description for boolean fields #498

Merged
merged 2 commits into from
Mar 3, 2017
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
9 changes: 6 additions & 3 deletions playground/samples/widgets.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,18 @@ module.exports = {
properties: {
default: {
type: "boolean",
title: "checkbox (default)"
title: "checkbox (default)",
description: "This is the checkbox-description"
},
radio: {
type: "boolean",
title: "radio buttons"
title: "radio buttons",
description: "This is the radio-description"
},
select: {
type: "boolean",
title: "select box"
title: "select box",
description: "This is the select-description"
}
}
},
Expand Down
3 changes: 2 additions & 1 deletion src/components/widgets/CheckboxWidget.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, {PropTypes} from "react";

import DescriptionField from "../fields/DescriptionField.js";

function CheckboxWidget({
schema,
Expand All @@ -13,6 +13,7 @@ function CheckboxWidget({
}) {
return (
<div className={`checkbox ${disabled ? "disabled" : ""}`}>
{ schema.description && <DescriptionField description={ schema.description }/> }
<label>
<input type="checkbox"
id={id}
Expand Down
10 changes: 10 additions & 0 deletions test/BooleanField_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,16 @@ describe("BooleanField", () => {
.to.have.length.of(1);
});

it("should render a description", () => {
const {node} = createFormComponent({schema: {
type: "boolean",
description: "my description"
}});

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

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