Skip to content

Commit

Permalink
Merge pull request #466 from netlify/hidden-nested
Browse files Browse the repository at this point in the history
hide hidden widget in object and list controls
  • Loading branch information
erquhart authored Jul 1, 2017
2 parents ae41bcb + 66a683b commit 2066024
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
2 changes: 2 additions & 0 deletions example/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ collections: # A list of collections the CMS should be able to edit
- {label: "Image", name: "image", widget: "image"}
- {label: "File", name: "file", widget: "file"}
- {label: "Select", name: "select", widget: "select", options: ["a", "b", "c"]}
- {label: "Hidden", name: "hidden", widget: "hidden", default: "hidden"}
- label: "Object"
name: "object"
widget: "object"
Expand Down Expand Up @@ -128,6 +129,7 @@ collections: # A list of collections the CMS should be able to edit
- {label: "Image", name: "image", widget: "image"}
- {label: "File", name: "file", widget: "file"}
- {label: "Select", name: "select", widget: "select", options: ["a", "b", "c"]}
- {label: "Hidden", name: "hidden", widget: "hidden", default: "hidden"}
- label: "Object"
name: "object"
widget: "object"
Expand Down
3 changes: 3 additions & 0 deletions src/components/Widgets/ObjectControl.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ export default class ObjectControl extends Component {

controlFor(field) {
const { onAddAsset, onRemoveAsset, getAsset, value, onChange } = this.props;
if (field.get('widget') === 'hidden') {
return null;
}
const widget = resolveWidget(field.get('widget') || 'string');
const fieldValue = value && Map.isMap(value) ? value.get(field.get('name')) : value;

Expand Down

0 comments on commit 2066024

Please sign in to comment.