Extend forms connectors definitions
If you have custom connector and you want it to have settings in the forms detail dialogs. You can achieve this using FormsConnectorDefinitionsExtender.
Add custom controls to forms section separated for the connectors, by performing the following:
-
Create your own class and implement the abstract
FormsConnectorDefinitionsExtender. -
Use the
AddConnectorsSettingsmethod to attach your custom controls to the form dialogs. Use the following sample:C#using System; using Telerik.Sitefinity.Configuration; using Telerik.Sitefinity.Modules.Forms; using Telerik.Sitefinity.Services; using Telerik.Sitefinity.Web.UI.Fields; using Telerik.Sitefinity.Web.UI.Fields.Config; using Telerik.Sitefinity.Web.UI.Fields.Enums; namespace SitefinityWebApp { public class ExtendFormConnector : FormsConnectorDefinitionsExtender { public override void AddConnectorSettings(ConfigElementDictionary<string, FieldDefinitionElement> sectionFields) { var myTextField = new TextFieldDefinitionElement(sectionFields) { Title = "myTextField", DataFieldName = string.Format("{0}.{1}", "Attributes", "myFieldName"), DisplayMode = FieldDisplayMode.Write, FieldName = "myFieldName", FieldType = typeof(TextField), ID = "myId", ResourceClassId = "myClass", }; sectionFields.Add(myTextField); } public override int Ordinal { get { return 1; } } public override string ConnectorName => "MyConnectorName"; public override string ConnectorTitle => "MyConnectorTitle"; public override string SectionTitle => "MyConnectorSectionTitle"; } }NOTE: Sitefinity CMS supports only the following definition elements as section fields:
TextFieldDefinitionElement,ChoiceFieldElement, andTaxonFieldDefinitionElement.NOTE:
FormsConnectorDefinitionsExtender.ConnectorNameandIModuleConnectionStatus.ModuleNamemust be equal. -
Implement the
IModuleConnectionStatusinterfaceSitefinity CMS displays the warning Connection to [Connector Title] is not set or lost. Check your connector settings and try again when the following conditions are met:
- Your connector does not implement the
IModuleConnectionStatusinterface. - The action callback of the
IModuleConnectionStatus.ExecuteIfConfiguredmethod was not executed.
To prevent showing this warning to the Sitefinity CMS user, implement the interface as the following example:
C#using System; using Telerik.Sitefinity.Configuration; using Telerik.Sitefinity.Modules.Forms; using Telerik.Sitefinity.Services; using Telerik.Sitefinity.Web.UI.Fields; using Telerik.Sitefinity.Web.UI.Fields.Config; using Telerik.Sitefinity.Web.UI.Fields.Enums; namespace SitefinityWebApp { public class ExtendFormConnectorConnectionStatus : IModuleConnectionStatus { public string ModuleName => "MyConnectorName"; public void ExecuteIfConfigured(Action action) { // Add code to check that the connector is connected // ex. if (this.connector.IsConnected()) if (action != null) action(); } // IMPORTANT: This callback is not invoked as part of Forms connectors. You still need to implement it, as it is used elsewhere. public void ExecuteIfNotConfigured(Action action) { // Add code to check that the connector is not configured // ex. if (!this.connector.IsConnected()) if (action != null) action(); } } } - Your connector does not implement the
-
Register your classes in the following way:
C#using System; using Telerik.Microsoft.Practices.Unity; using Telerik.Sitefinity.Abstractions; using Telerik.Sitefinity.Services; namespace SitefinityWebApp { public class Global : System.Web.HttpApplication { protected void Application_Start(object sender, EventArgs e) { Bootstrapper.Bootstrapped += Bootstrapper_Bootstrapped; } private void Bootstrapper_Bootstrapped(object sender, EventArgs e) { ObjectFactory.Container.RegisterType<Telerik.Sitefinity.Modules.Forms.FormsConnectorDefinitionsExtender, ExtendFormConnector>("ExtendFormConnector"); ObjectFactory.Container.RegisterType<IModuleConnectionStatus, ExtendFormConnectorConnectionStatus>(typeof(ExtendFormConnectorConnectionStatus).FullName, new ContainerControlledLifetimeManager()); } } }The
Ordinalproperty is used to sort the connectors settings.