Skip to content

Commit

Permalink
Using 'ui:order' to avoid field name collisions.
Browse files Browse the repository at this point in the history
  • Loading branch information
n1k0 committed Jan 9, 2016
1 parent f660dd4 commit 2998175
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 9 deletions.
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ Here's a list of supported alternative widgets for different JSONSchema data typ
## Object fields ordering

The `uiSchema` object spec also allows you to define in which order a given object field properties should be rendered using the `order` property:
The `uiSchema` object spec also allows you to define in which order a given object field properties should be rendered using the `ui:order` property:

```jsx
const schema = {
Expand All @@ -129,12 +129,11 @@ const schema = {
};

const uiSchema = {
order: ["bar", "foo"]
"ui:order": ["bar", "foo"]
};

render((
<Form schema={schema}
uiSchema={uiSchema} />
<Form schema={schema} uiSchema={uiSchema} />
), document.getElementById("app"));
```

Expand Down
2 changes: 1 addition & 1 deletion playground/samples/ordering.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ module.exports = {
}
},
uiSchema: {
order: ["firstName", "lastName", "age", "bio", "password"],
"ui:order": ["firstName", "lastName", "age", "bio", "password"],
age: {
widget: "updown"
},
Expand Down
2 changes: 1 addition & 1 deletion src/components/fields/ObjectField.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class ObjectField extends Component {
const SchemaField = this.props.SchemaField;
try {
var orderedProperties = orderProperties(
Object.keys(schema.properties), uiSchema.order);
Object.keys(schema.properties), uiSchema["ui:order"]);
} catch(err) {
return (
<p className="config-error" style={{color: "red"}}>
Expand Down
6 changes: 3 additions & 3 deletions test/index_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ describe("Form", () => {

it("should use provided order", () => {
const {node} = createComponent({schema, uiSchema: {
order: ["bar", "foo"]
"ui:order": ["bar", "foo"]
}});
const labels = [].map.call(
node.querySelectorAll(".field > label"), l => l.textContent);
Expand All @@ -82,7 +82,7 @@ describe("Form", () => {

it("should throw when order list length mismatches", () => {
const {node} = createComponent({schema, uiSchema: {
order: ["bar", "foo", "baz?"]
"ui:order": ["bar", "foo", "baz?"]
}});

expect(node.querySelector(".config-error").textContent)
Expand All @@ -91,7 +91,7 @@ describe("Form", () => {

it("should throw when order and properties lists differs", () => {
const {node} = createComponent({schema, uiSchema: {
order: ["bar", "wut?"]
"ui:order": ["bar", "wut?"]
}});

expect(node.querySelector(".config-error").textContent)
Expand Down

0 comments on commit 2998175

Please sign in to comment.