Hi,
I am using Sitefinity v10.2 and needed a Custom MVC Document Selector. Currently, I am using the code provided at:
However, the custom widget is showing the "Change document" dialog when it has no document bound to it initially.
Yet, the built-in document selector is showing the correct dialog when it has no document bound to it initially.
I have tried adding the sf-auto-open-selector to the sf-media-field tag in DesignerView.Simple.cshtml, but no luck. Any advice?
<form>
<div class="form-group"> <label for="document-field" class="m-top-sm">Document</label> <sf-media-field class="sf-Media--info modal-settings modal-settings-space" sf-auto-open-selector sf-media-type="documents" sf-model="properties.DocumentId.PropertyValue" sf-media="selectedMedia" sf-provider="properties.DocumentProviderName.PropertyValue" id="document-field"></sf-media-field> </div>
</form>
Thanks!
Do you have the sf-document-selector in your DesignerView.Simple.json?
Should like something like below:
{ "priority": 1, "components": ["sf-document-selector"] }
https://www.progress.com/documentation/sitefinity-cms/use-components-to-resolve-script-dependencies-mvc
This json file lets Sitefinity know you want to load the Simple view as the default designer and also loads the components needs for the selector.
Thanks jread! I was able to get the correct initial dialog after adding "sf-document-selector" to DesignerView.Simple.json.
However, when I close the initial dialog without selecting any document, I still see the "change document" dialog. The built-in document link does not seem to have this behaviour. Any clue?
Not 100% on why that would be happening. Does you set any default values for the properties in the controller? it's possible it thinks you have a selected item when you don't actually do?