In the WebApp, is it possible to have some logic in Content Types to show or hide fields depending on the value of other fields when we create Content?
For example, let’s say our Content Type have two fields:
Nationality (mandatory): a dropdown menu with two options: [“US citizen”, “Other”].
Country (optional): a dropdown menu with several countries
In this case, if nationality is “US citizen” we don’t need to fill the country field so it would be great to hide this field.
Hi @gabriel, would you be able to elaborate a little bit more on this. I’m trying to do this from a UI Extension and I’m able to access the controls of the content type using the SDK property (sdk.editor.editorInterface.controls) but I don’t know how to manipulate the visibility of the fields using the SDK and when trying to do it via JS, the browser blocks the script because of the cross-origin frame policy.
After looking into this for some while now… it doesn’t seem to be possible to change the visibility of a field using an external app.
As @fluxa mentioned, an external application is not allowed to access the parent document from within the iframe, you will get a DOMException.
So the only way seems to be to host the application with contentful, or write an extension.