Hi Hüseyin
You should be able to set the value of Forms_ConnectedDataSource on all FormContainerBlock types in the ContentCreating event in an Episerver Intialisation module.
https://world.episerver.com/documentation/class-library/?documentId=cms/11/81F308A
https://world.episerver.com/documentation/developer-guides/CMS/initialization/
David
Hello David,
Thanks for your answer. It is possible to get the form container during an initialisation script by casting e.Content to the form container. However, the form block does not contain any property for ConnectedDataSource. Am I looking at the wrong place?
private void OnCreatingContent(object sender, ContentEventArgs e) { if (!(e.Content is CustomFormContainer customFormContainer)) return; sbgFormContainer. //The object does not expose ConnectedDataSource }
Hi Hüseyin
Its not exposed as a strongly typed property but you should be able to access it using the property collection. Something like:
((CustomFormContainer)sbgFormContainer).Property["Forms_ConnectedDataSource"] = <<your value here>>
David
Hi, thanks for the tip!
I see, the property accepts a PropertyConnectedDataSourceCollection object. Is it okay to initiate this only using the ID value? Otherwise, how can I create this object? One alternative can be to hold an instance where I copy the properties from, are there any other ways.
The collection extends PropertyLongString so you could look at the string value on a configured form and set that in your init module
Hello,
I have a custom form container that is inherited from FormContainerBlock. How do I set its default data source to an existing implementation of IExternalSystem? I want every instance of this form container should have the default data source.