Merge pull request #466 from netlify/hidden-nested

hide hidden widget in object and list controls
This commit is contained in:
Shawn Erquhart 2017-06-30 21:46:57 -04:00 committed by GitHub
commit 206602436c
2 changed files with 5 additions and 0 deletions

View File

@ -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"
@ -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"

View File

@ -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;