Skip to content

Instantly share code, notes, and snippets.

@almet
Last active June 1, 2016 15:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save almet/ffd37fce93bdc9ba27f9f0abe724844e to your computer and use it in GitHub Desktop.
Save almet/ffd37fce93bdc9ba27f9f0abe724844e to your computer and use it in GitHub Desktop.
diff --git a/playground/samples/arrays.js b/playground/samples/arrays.js
index 12e2c9f..db2cff0 100644
--- a/playground/samples/arrays.js
+++ b/playground/samples/arrays.js
@@ -53,6 +53,9 @@ module.exports = {
}
},
uiSchema: {
+ multipleChoicesList: {
+ "ui:widget": "checkboxes"
+ },
fixedItemsList: {
items: [
{"ui:widget": "textarea"},
diff --git a/src/utils.js b/src/utils.js
index e9a085c..854da13 100644
--- a/src/utils.js
+++ b/src/utils.js
@@ -19,6 +19,7 @@ import TextareaWidget from "./components/widgets/TextareaWidget";
import HiddenWidget from "./components/widgets/HiddenWidget";
import ColorWidget from "./components/widgets/ColorWidget";
import FileWidget from "./components/widgets/FileWidget";
+import CheckboxesWidget from "./components/widgets/CheckboxesWidget";
@@ -27,6 +28,7 @@ const altWidgetMap = {
radio: RadioWidget,
select: SelectWidget,
hidden: HiddenWidget,
+ checkboxes: CheckboxesWidget,
},
string: {
password: PasswordWidget,
@@ -40,6 +42,7 @@ const altWidgetMap = {
"alt-datetime": AltDateTimeWidget,
color: ColorWidget,
file: FileWidget,
+ checkboxes: CheckboxesWidget,
},
number: {
updown: UpDownWidget,
diff --git a/test/ArrayField_test.js b/test/ArrayField_test.js
index 8178801..4590b61 100644
--- a/test/ArrayField_test.js
+++ b/test/ArrayField_test.js
@@ -192,6 +192,17 @@ describe("ArrayField", () => {
value: ["foo", "fuzz"]
};
+ it.only("should be possible to specify a custom widget", () => {
+ const uiSchema = {
+ "items": {"ui:widget": "checkboxes"}
+ };
+ const {node} = createFormComponent({schema, uiSchema});
+ d(node);
+
+ expect(node.querySelectorAll("select"))
+ .to.have.length.of(1);
+ });
+
it("should render a select widget", () => {
const {node} = createFormComponent({schema});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment