Reputation: 22923
We have a block type in our EpiServer project that can have either specify a video to use (an EPiServer.Url
) or a youtube id (string
). The thing is that it only makes sense to use either of those, not both. Is there a way of marking one field readonly if the other is filled?
Upvotes: 0
Views: 47
Reputation: 7391
Not using vanilla editors, I'm afraid. But you could fairly easily create a custom editor (dojo widget) for that use case.
Here's an example of a custom editor to display a checkbox list for selecting blocks, instead of the standard editor for ContentArea properties: https://tedgustaf.com/blog/2016/create-a-custom-editor-for-a-content-area-in-episerver/
However, the same principles apply for any content type.
To be clear: you don't need a custom property type, just a custom editor. The backing property type could still be string, which would contain either the URL or the YouTube ID.
If you want the property to be more developer-friendly, you could create a block type with "YouTube ID" and "URL" properties, and then define a content property of that block type.
You would then use your custom editor to set either the "YouTube ID" or "URL" property of that "VideoBlock" property.
We have created a similar editor before, where the editor would either select a video using a dropdown, or specify a custom video stream URL.
Upvotes: 1