private static void CreateBackendSections(DetailFormViewElement detailView, FieldDisplayMode displayMode)
        {
            #region Toolbar section

            if (detailView.ViewName == ProductsDefinitions.BackendEditViewName)
            {
                var toolbarSection = new ContentViewSectionElement(detailView.Sections)
                {
                    Name = DefinitionsHelper.ToolbarSectionName
                };

                var languageListFieldElement = new LanguageListFieldElement(toolbarSection.Fields)
                {
                    ID = "languageListField",
                    FieldType = typeof(LanguageListField),
                    ResourceClassId = typeof(LocalizationResources).Name,
                    Title = "OtherTranslationsColon",
                    DisplayMode = displayMode,
                    FieldName = "languageListField",
                    DataFieldName = "AvailableLanguages"
                };
                toolbarSection.Fields.Add(languageListFieldElement);

                detailView.Sections.Add(toolbarSection);
            }

            #endregion

            #region Main section

            var mainSection = new ContentViewSectionElement(detailView.Sections)
            {
                Name = "MainSection",
                CssClass = "sfFirstForm"
            };

            var titleField = new TextFieldDefinitionElement(mainSection.Fields)
            {
                ID = "titleFieldControl",
                DataFieldName = (displayMode == FieldDisplayMode.Write) ? "Title.PersistedValue" : "Title",
                DisplayMode = displayMode,
                Title = "lTitle",
                CssClass = "sfTitleField",
                ResourceClassId = typeof(ProductsResources).Name,
                WrapperTag = HtmlTextWriterTag.Li,
            };
            titleField.ValidatorConfig = new ValidatorDefinitionElement(titleField)
            {
                Required = true,
                MessageCssClass = "sfError",
                RequiredViolationMessage = "TitleCannotBeEmpty",
                ResourceClassId = typeof(ProductsResources).Name
            };
            mainSection.Fields.Add(titleField);

            if (detailView.ViewName == ProductsDefinitions.BackendEditViewName || detailView.ViewName == ProductsDefinitions.BackendInsertViewName)
            {
                var languageChoiceField = new ChoiceFieldElement(mainSection.Fields)
                {
                    ID = "languageChoiceField",
                    FieldType = typeof(LanguageChoiceField),
                    ResourceClassId = typeof(ProductsResources).Name,
                    Title = "Language",
                    DisplayMode = displayMode,
                    FieldName = "languageField",
                    RenderChoiceAs = RenderChoicesAs.DropDown,
                    MutuallyExclusive = true,
                    DataFieldName = "AvailableLanguages"
                };
                mainSection.Fields.Add(languageChoiceField);
            }

            var dropDownTaxonomyField = new TaxonFieldDefinitionElement(mainSection.Fields)
            {
                ID = "testTaxonomyField",
                Title = "Colors",
                DataFieldName = "Colors",
                TaxonomyId = ProductsModule.ColorsTaxonomyId,
                FieldType = typeof(TaxonomyDropDownField),
                DisplayMode = displayMode,
            };
            mainSection.Fields.Add(dropDownTaxonomyField);

            var contentField = new HtmlFieldElement(mainSection.Fields)
            {
                ID = "contentFieldControl",
                DataFieldName = (displayMode == FieldDisplayMode.Write) ? "Content.PersistedValue" : "Content",
                DisplayMode = displayMode,
                CssClass = "sfFormSeparator sfContentField",
                ResourceClassId = typeof(ProductsResources).Name,
                WrapperTag = HtmlTextWriterTag.Li,
                EditorContentFilters = Telerik.Web.UI.EditorFilters.DefaultFilters,
                EditorStripFormattingOptions = (Telerik.Web.UI.EditorStripFormattingOptions?)(Telerik.Web.UI.EditorStripFormattingOptions.MSWord | Telerik.Web.UI.EditorStripFormattingOptions.Css | Telerik.Web.UI.EditorStripFormattingOptions.Font | Telerik.Web.UI.EditorStripFormattingOptions.Span | Telerik.Web.UI.EditorStripFormattingOptions.ConvertWordLists)
            };
            mainSection.Fields.Add(contentField);

            //Product Image
            var productImageField = new ImageFieldElement(mainSection.Fields)
            {
                ID = "avatarField",
                DataFieldName = "ProductImage",
                DisplayMode = displayMode,
                UploadMode = ImageFieldUploadMode.Dialog,
                Title = "ProductImageFieldTitle",
                WrapperTag = HtmlTextWriterTag.Li,
                CssClass = "sfUserAvatar",
                ResourceClassId = typeof(ProductsResources).Name,
                DataFieldType = typeof(ContentLink),
                DefaultSrc = "~/SFRes/images/ProductCatalogSample/Images.NoProductImage.png", // put your default image location example: 
                SizeInPx = 100
            };
            mainSection.Fields.Add(productImageField);

            var summaryField = new TextFieldDefinitionElement(mainSection.Fields)
            {
                ID = "whatsInTheBoxFieldControl",
                DataFieldName = (displayMode == FieldDisplayMode.Write) ? "WhatIsInTheBox.PersistedValue" : "WhatIsInTheBox",
                DisplayMode = displayMode,
                Title = "WhatIsInTheBox",
                CssClass = "sfFormSeparator",
                WrapperTag = HtmlTextWriterTag.Li,
                ResourceClassId = typeof(ProductsResources).Name,
                Rows = 5
            };
            summaryField.ExpandableDefinitionConfig = new ExpandableControlElement(summaryField)
            {
                Expanded = false,
                ExpandText = "ClickToAddSummary",
                ResourceClassId = typeof(ProductsResources).Name
            };
            summaryField.ValidatorConfig.Required = false;
            mainSection.Fields.Add(summaryField);


            var quantityField = new TextFieldDefinitionElement(mainSection.Fields)
            {
                ID = "quantityFieldControl",
                DataFieldName = "QuantityInStock",
                DisplayMode = displayMode,
                Title = "QuantityInStock",
                CssClass = "sfTitleField",
                ResourceClassId = typeof(ProductsResources).Name,
                WrapperTag = HtmlTextWriterTag.Li
            };
            quantityField.ValidatorConfig = new ValidatorDefinitionElement(quantityField)
            {
                Required = true,
                MessageCssClass = "sfError",
                RequiredViolationMessage = "TitleCannotBeEmpty",
                ResourceClassId = typeof(ProductsResources).Name,
                RegularExpression = "^[0-9]+[.]*[0-9]*$",
                RegularExpressionViolationMessage = "TheQuantityMustBeAPositiveNumber"
            };
            mainSection.Fields.Add(quantityField);

            var priceField = new TextFieldDefinitionElement(mainSection.Fields)
            {
                ID = "priceFieldControl",
                DataFieldName = "Price",
                DisplayMode = displayMode,
                Title = "Price",
                CssClass = "sfTitleField",
                ResourceClassId = typeof(ProductsResources).Name,
                WrapperTag = HtmlTextWriterTag.Li,
            };
            priceField.ValidatorConfig = new ValidatorDefinitionElement(priceField)
            {
                Required = true,
                MessageCssClass = "sfError",
                RequiredViolationMessage = "TitleCannotBeEmpty",
                ResourceClassId = typeof(ProductsResources).Name,
                RegularExpression = "^[0-9]+[.]*[0-9]*$",
                RegularExpressionViolationMessage = "ThePriceMustBeAPositiveNumber"
            };
            mainSection.Fields.Add(priceField);

            detailView.Sections.Add(mainSection);

            #endregion

            #region Categories and Tags
            var taxonSection = new ContentViewSectionElement(detailView.Sections)
            {
                Name = "TaxonSection",
                Title = "CategoriesAndTags",
                ResourceClassId = typeof(ProductsResources).Name,
                CssClass = "sfExpandableForm",
                ExpandableDefinitionConfig =
                {
                    Expanded = false
                }
            };

            var categories = DefinitionTemplates.CategoriesFieldWriteMode(taxonSection.Fields);
            categories.DisplayMode = displayMode;
            taxonSection.Fields.Add(categories);

            var tags = DefinitionTemplates.TagsFieldWriteMode(taxonSection.Fields);
            tags.DisplayMode = displayMode;
            tags.CssClass = "sfFormSeparator";
            tags.ExpandableDefinition.Expanded = true;
            tags.Description = "TagsFieldInstructions";
            taxonSection.Fields.Add(tags);

            detailView.Sections.Add(taxonSection);
            #endregion

            #region More options section

            var moreOptionsSection = new ContentViewSectionElement(detailView.Sections)
            {
                Name = "MoreOptionsSection",
                Title = "MoreOptionsURL",
                ResourceClassId = typeof(ProductsResources).Name,
                CssClass = "sfExpandableForm",
                ExpandableDefinitionConfig =
                {
                    Expanded = false
                }
            };

            if (displayMode == FieldDisplayMode.Write)
            {
                var urlName = new MirrorTextFieldElement(moreOptionsSection.Fields)
                {
                    Title = "UrlName",
                    ResourceClassId = typeof(ProductsResources).Name,
                    ID = "urlName",
                    MirroredControlId = titleField.ID,
                    DataFieldName = (displayMode == FieldDisplayMode.Write) ? "UrlName.PersistedValue" : "UrlName",
                    DisplayMode = displayMode,
                    RegularExpressionFilter = DefinitionsHelper.UrlRegularExpressionFilter,
                    WrapperTag = HtmlTextWriterTag.Li,
                    ReplaceWith = "-"
                };
                var validationDef = new ValidatorDefinitionElement(urlName)
                {
                    Required = true,
                    MessageCssClass = "sfError",
                    RequiredViolationMessage = Res.Get<ProductsResources>().UrlNameCannotBeEmpty,
                    RegularExpression = DefinitionsHelper.UrlRegularExpressionFilterForValidator,
                    RegularExpressionViolationMessage = Res.Get<PageResources>().UrlNameInvalidSymbols
                };
                urlName.ValidatorConfig = validationDef;

                moreOptionsSection.Fields.Add(urlName);
            }

            var allowCommentsFieldElement = new ChoiceFieldElement(moreOptionsSection.Fields)
            {
                ID = "allowCommentsField",
                Title = (displayMode == FieldDisplayMode.Read) ? "AllowComments" : string.Empty,
                DataFieldName = "AllowComments",
                DisplayMode = displayMode,
                RenderChoiceAs = RenderChoicesAs.SingleCheckBox,
                CssClass = "sfCheckBox sfFormSeparator",
                WrapperTag = HtmlTextWriterTag.Li,
                ResourceClassId = typeof(ProductsResources).Name
            };
            allowCommentsFieldElement.ChoicesConfig.Add(
                new ChoiceElement(allowCommentsFieldElement.ChoicesConfig)
                {
                    Text = "AllowComments",
                    ResourceClassId = typeof(ProductsResources).Name
                });
            moreOptionsSection.Fields.Add(allowCommentsFieldElement);

            detailView.Sections.Add(moreOptionsSection);

            #endregion

            #region Sidebar

            if (displayMode == FieldDisplayMode.Write)
            {
                var sidebar = new ContentViewSectionElement(detailView.Sections)
                {
                    Name = DefinitionsHelper.SidebarSectionName,
                    CssClass = "sfItemReadOnlyInfo"
                };

                sidebar.Fields.Add(new ContentWorkflowStatusInfoFieldElement(sidebar.Fields)
                {
                    DisplayMode = displayMode,
                    FieldName = "NewsWorkflowStatusInfoField",
                    ResourceClassId = typeof(ProductsResources).Name,
                    WrapperTag = HtmlTextWriterTag.Li,
                    FieldType = typeof(ContentWorkflowStatusInfoField)
                });

                detailView.Sections.Add(sidebar);
            }

            #endregion

        }
		/// <summary>
		/// Creates the backend sections. Adds edit/preview controls to the detailView
		/// </summary>
		/// <param name="detailView">The detail view.</param>
		/// <param name="displayMode">The display mode.</param>
		private static void CreateBackendSections(DetailFormViewElement detailView, FieldDisplayMode displayMode)
		{
			// define main content section
			var mainSection = new ContentViewSectionElement(detailView.Sections)
			{
				Name = "MainSection",
				CssClass = "sfFirstForm"
			};

			#region Title Field

			// define title field element
			var titleField = new TextFieldDefinitionElement(mainSection.Fields)
			{
				ID = "titleFieldControl",
				DataFieldName = displayMode == FieldDisplayMode.Write ? "Title.PersistedValue" : "Title",
				DisplayMode = displayMode,
				Title = "Title",
				CssClass = "sfTitleField",
				WrapperTag = HtmlTextWriterTag.Li,
			};

			// add validation
			titleField.ValidatorConfig = new ValidatorDefinitionElement(titleField)
			{
				Required = true,
				MessageCssClass = "sfError",
				RequiredViolationMessage = "Title field is required"
			};

			// add field to section
			mainSection.Fields.Add(titleField);

			#endregion

			#region Content

			var contentField = new HtmlFieldElement(mainSection.Fields)
			{
				ID = "contentFieldControl",
				DataFieldName = displayMode == FieldDisplayMode.Write ? "Content.PersistedValue" : "Content",
				DisplayMode = displayMode,
				CssClass = "sfFormSeparator sfContentField",
				WrapperTag = HtmlTextWriterTag.Li,
				EditorContentFilters = Telerik.Web.UI.EditorFilters.DefaultFilters,
				EditorStripFormattingOptions = (EditorStripFormattingOptions?)(EditorStripFormattingOptions.MSWord | EditorStripFormattingOptions.Css | EditorStripFormattingOptions.Font | EditorStripFormattingOptions.Span | EditorStripFormattingOptions.ConvertWordLists)
			};
			mainSection.Fields.Add(contentField);

			#endregion

			#region Address fields

			// Address field
			var addressField = new TextFieldDefinitionElement(mainSection.Fields)
			{
				ID = "addressFieldControl",
				DataFieldName = "Address",
				DisplayMode = displayMode,
				Title = "Address",
				CssClass = "sfTitleField",
				WrapperTag = HtmlTextWriterTag.Li
			};
			addressField.ValidatorConfig = new ValidatorDefinitionElement(addressField)
			{
				Required = true,
				MessageCssClass = "sfError",
				RequiredViolationMessage = "Location address is required"
			};
			mainSection.Fields.Add(addressField);

			// City field
			var cityField = new TextFieldDefinitionElement(mainSection.Fields)
			{
				ID = "cityFieldControl",
				DataFieldName = "City",
				DisplayMode = displayMode,
				Title = "City",
				CssClass = "sfTitleField",
				WrapperTag = HtmlTextWriterTag.Li
			};
			mainSection.Fields.Add(cityField);

			// State / Region field
			var regionField = new TextFieldDefinitionElement(mainSection.Fields)
			{
				ID = "regionFieldControl",
				DataFieldName = "Region",
				DisplayMode = displayMode,
				Title = "State / Region",
				CssClass = "sfTitleField",
				WrapperTag = HtmlTextWriterTag.Li
			};
			regionField.ValidatorConfig = new ValidatorDefinitionElement(regionField)
			{
				Required = true,
				MessageCssClass = "sfError",
				RequiredViolationMessage = "State / Region is a required field"
			};
			mainSection.Fields.Add(regionField);

			// Postal Code field
			var postalCodeField = new TextFieldDefinitionElement(mainSection.Fields)
			{
				ID = "postalCodeFieldControl",
				DataFieldName = "PostalCode",
				DisplayMode = displayMode,
				Title = "Postal Code",
				CssClass = "sfTitleField",
				WrapperTag = HtmlTextWriterTag.Li
			};
			postalCodeField.ValidatorConfig = new ValidatorDefinitionElement(postalCodeField)
			{
				Required = true,
				MessageCssClass = "sfError",
				RequiredViolationMessage = "Postal code is a required field"
			};
			mainSection.Fields.Add(postalCodeField);

			// Country field
			var countryField = new TextFieldDefinitionElement(mainSection.Fields)
			{
				ID = "countryFieldControl",
				DataFieldName = "Country",
				DisplayMode = displayMode,
				Title = "Country",
				CssClass = "sfTitleField",
				WrapperTag = HtmlTextWriterTag.Li
			};

			countryField.ValidatorConfig = new ValidatorDefinitionElement(countryField)
			{
				Required = true,
				MessageCssClass = "sfError",
				RequiredViolationMessage = "Country is a required field"
			};

			mainSection.Fields.Add(countryField);

			// add section to view
			detailView.Sections.Add(mainSection);

			#endregion

			#region Categories and Tags Section

			// define new section
			var taxonSection = new ContentViewSectionElement(detailView.Sections)
			{
				Name = "TaxonSection",
				Title = "Categories and Tags",
				CssClass = "sfExpandableForm",
				ExpandableDefinitionConfig =
				{
					Expanded = false
				}
			};

			// add categories field to section
			var categories = DefinitionTemplates.CategoriesFieldWriteMode(taxonSection.Fields);
			categories.DisplayMode = displayMode;

			// add categories section to view
			taxonSection.Fields.Add(categories);

			// add tags field to section
			var tags = DefinitionTemplates.TagsFieldWriteMode(taxonSection.Fields);
			tags.DisplayMode = displayMode;
			tags.CssClass = "sfFormSeparator";
			tags.ExpandableDefinition.Expanded = true;
			tags.Description = "TagsFieldInstructions";
			taxonSection.Fields.Add(tags);

			// add tags section to view
			detailView.Sections.Add(taxonSection);

			#endregion

			#region More options Section

			// define new section
			var moreOptionsSection = new ContentViewSectionElement(detailView.Sections)
			{
				Name = "MoreOptionsSection",
				Title = "More Options",
				CssClass = "sfExpandableForm",
				ExpandableDefinitionConfig =
				{
					Expanded = false
				}
			};

			// Url field for insert view
			if (displayMode == FieldDisplayMode.Write)
			{
                var urlName = new MirrorTextFieldElement(moreOptionsSection.Fields)
                {
                    Title = "URL",
                    ID = "urlName",
                    MirroredControlId = titleField.ID,
                    DataFieldName = "UrlName.PersistedValue",
                    DisplayMode = displayMode,
                    RegularExpressionFilter = DefinitionsHelper.UrlRegularExpressionFilter,
                    WrapperTag = HtmlTextWriterTag.Li,
                    ReplaceWith = "-"
                };
                var validationDef = new ValidatorDefinitionElement(urlName)
                {
                    Required = true,
                    MessageCssClass = "sfError",
                    RequiredViolationMessage = "Url cannot be empty",
                    RegularExpression = DefinitionsHelper.UrlRegularExpressionFilterForValidator,
                    RegularExpressionViolationMessage = "Invalid Url"
                };
                urlName.ValidatorConfig = validationDef;

                moreOptionsSection.Fields.Add(urlName);
			}

			// add url section to view
			detailView.Sections.Add(moreOptionsSection);

			#endregion
		}
        private static void CreateBackendSections(DetailFormViewElement detailView, FieldDisplayMode displayMode)
        {
            #region Toolbar section

            if (detailView.ViewName == AgentsDefinitions.BackendEditViewName)
            {
                var toolbarSection = new ContentViewSectionElement(detailView.Sections)
                {
                    Name = DefinitionsHelper.ToolbarSectionName
                };

                var languageListFieldElement = new LanguageListFieldElement(toolbarSection.Fields)
                {
                    ID = "languageListField",
                    FieldType = typeof(LanguageListField),
                    ResourceClassId = typeof(LocalizationResources).Name,
                    Title = "OtherTranslationsColon",
                    DisplayMode = displayMode,
                    FieldName = "languageListField",
                    DataFieldName = "AvailableLanguages"
                };
                toolbarSection.Fields.Add(languageListFieldElement);

                detailView.Sections.Add(toolbarSection);
            }

            #endregion

            #region Main section

            var mainSection = new ContentViewSectionElement(detailView.Sections)
            {
                Name = "MainSection",
                CssClass = "sfFirstForm"
            };

            var titleField = new TextFieldDefinitionElement(mainSection.Fields)
            {
                ID = "titleFieldControl",
                DataFieldName = (displayMode == FieldDisplayMode.Write) ? "Title.PersistedValue" : "Title",
                DisplayMode = displayMode,
                Title = "lTitle",
                CssClass = "sfTitleField",
                ResourceClassId = typeof(AgentsResources).Name,
                WrapperTag = HtmlTextWriterTag.Li,
            };
            titleField.ValidatorConfig = new ValidatorDefinitionElement(titleField)
            {
                Required = true,
                MessageCssClass = "sfError",
                RequiredViolationMessage = "TitleCannotBeEmpty",
                ResourceClassId = typeof(AgentsResources).Name
            };
            mainSection.Fields.Add(titleField);

            if (detailView.ViewName == AgentsDefinitions.BackendEditViewName || detailView.ViewName == AgentsDefinitions.BackendInsertViewName)
            {
                var languageChoiceField = new ChoiceFieldElement(mainSection.Fields)
                {
                    ID = "languageChoiceField",
                    FieldType = typeof(LanguageChoiceField),
                    ResourceClassId = typeof(AgentsResources).Name,
                    Title = "Language",
                    DisplayMode = displayMode,
                    FieldName = "languageField",
                    RenderChoiceAs = RenderChoicesAs.DropDown,
                    MutuallyExclusive = true,
                    DataFieldName = "AvailableLanguages"
                };
                mainSection.Fields.Add(languageChoiceField);
            }

            var emailField = new TextFieldDefinitionElement(mainSection.Fields)
            {
                ID = "emailFieldControl",
                DataFieldName = "Email",
                DisplayMode = displayMode,
                Title = "Email",
                CssClass = "sfTitleField",
                ResourceClassId = typeof(AgentsResources).Name,
                WrapperTag = HtmlTextWriterTag.Li
            };
            emailField.ValidatorConfig = new ValidatorDefinitionElement(emailField)
            {
                Required = true,
                MessageCssClass = "sfError",
                RequiredViolationMessage = "EmailCannotBeEmpty",
                RegularExpression = @"^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$",
                RegularExpressionViolationMessage = "EmailMustBeValid",
                ResourceClassId = typeof(AgentsResources).Name
            };
            mainSection.Fields.Add(emailField);

            var phoneNumberField = new TextFieldDefinitionElement(mainSection.Fields)
            {
                ID = "phoneNumberFieldControl",
                DataFieldName = "PhoneNumber",
                DisplayMode = displayMode,
                Title = "PhoneNumber",
                CssClass = "sfTitleField",
                ResourceClassId = typeof(AgentsResources).Name,
                WrapperTag = HtmlTextWriterTag.Li
            };
            mainSection.Fields.Add(phoneNumberField);

            var addressField = new TextFieldDefinitionElement(mainSection.Fields)
            {
                ID = "addressFieldControl",
                DataFieldName = "Address",
                DisplayMode = displayMode,
                Title = "Address",
                CssClass = "sfTitleField",
                ResourceClassId = typeof(AgentsResources).Name,
                WrapperTag = HtmlTextWriterTag.Li
            };
            mainSection.Fields.Add(addressField);

            var postalCodeField = new TextFieldDefinitionElement(mainSection.Fields)
            {
                ID = "postalCodeFieldControl",
                DataFieldName = "PostalCode",
                DisplayMode = displayMode,
                Title = "PostalCode",
                CssClass = "sfTitleField",
                ResourceClassId = typeof(AgentsResources).Name,
                WrapperTag = HtmlTextWriterTag.Li
            };
            mainSection.Fields.Add(postalCodeField);

            detailView.Sections.Add(mainSection);

            #endregion

            #region Categories and Tags
            var taxonSection = new ContentViewSectionElement(detailView.Sections)
            {
                Name = "TaxonSection",
                Title = "CategoriesAndTags",
                ResourceClassId = typeof(AgentsResources).Name,
                CssClass = "sfExpandableForm",
                ExpandableDefinitionConfig =
                {
                    Expanded = false
                }
            };

            var categories = DefinitionTemplates.CategoriesFieldWriteMode(taxonSection.Fields);
            categories.DisplayMode = displayMode;
            taxonSection.Fields.Add(categories);

            var tags = DefinitionTemplates.TagsFieldWriteMode(taxonSection.Fields);
            tags.DisplayMode = displayMode;
            tags.CssClass = "sfFormSeparator";
            tags.ExpandableDefinition.Expanded = true;
            tags.Description = "TagsFieldInstructions";
            taxonSection.Fields.Add(tags);

            detailView.Sections.Add(taxonSection);
            #endregion

            #region More options section

            var moreOptionsSection = new ContentViewSectionElement(detailView.Sections)
            {
                Name = "MoreOptionsSection",
                Title = "MoreOptionsURL",
                ResourceClassId = typeof(AgentsResources).Name,
                CssClass = "sfExpandableForm",
                ExpandableDefinitionConfig =
                {
                    Expanded = false
                }
            };

            if (displayMode == FieldDisplayMode.Write)
            {
                var urlName = new MirrorTextFieldElement(moreOptionsSection.Fields)
                {
                    Title = "UrlName",
                    ID = "urlName",
                    MirroredControlId = titleField.ID,
                    DataFieldName = "UrlName.PersistedValue",
                    DisplayMode = displayMode,
                    RegularExpressionFilter = DefinitionsHelper.UrlRegularExpressionFilter,
                    WrapperTag = HtmlTextWriterTag.Li,
                    ReplaceWith = "-",
                    ResourceClassId = typeof(AgentsResources).Name
                };
                var validationDef = new ValidatorDefinitionElement(urlName)
                {
                    Required = true,
                    MessageCssClass = "sfError",
                    RequiredViolationMessage = "UrlNameCannotBeEmpty",
                    RegularExpression = DefinitionsHelper.UrlRegularExpressionFilterForValidator,
                    RegularExpressionViolationMessage = "UrlNameInvalid",
                    ResourceClassId = typeof(AgentsResources).Name
                };
                urlName.ValidatorConfig = validationDef;

                moreOptionsSection.Fields.Add(urlName);
            }

            detailView.Sections.Add(moreOptionsSection);

            #endregion

            #region Sidebar

            if (displayMode == FieldDisplayMode.Write)
            {
                var sidebar = new ContentViewSectionElement(detailView.Sections)
                {
                    Name = DefinitionsHelper.SidebarSectionName,
                    CssClass = "sfItemReadOnlyInfo"
                };

                sidebar.Fields.Add(new ContentWorkflowStatusInfoFieldElement(sidebar.Fields)
                {
                    DisplayMode = displayMode,
                    FieldName = "NewsWorkflowStatusInfoField",
                    ResourceClassId = typeof(AgentsResources).Name,
                    WrapperTag = HtmlTextWriterTag.Li,
                    FieldType = typeof(ContentWorkflowStatusInfoField)
                });

                detailView.Sections.Add(sidebar);
            }

            #endregion

        }
Example #4
0
        /// <summary>
        /// Creates the backend sections. Adds edit/preview controls to the detailView
        /// </summary>
        /// <param name="detailView">The detail view.</param>
        /// <param name="displayMode">The display mode.</param>
        private static void CreateBackendSections(DetailFormViewElement detailView, FieldDisplayMode displayMode)
        {
            // define main content section
            var mainSection = new ContentViewSectionElement(detailView.Sections)
            {
                Name     = "MainSection",
                CssClass = "sfFirstForm"
            };

            #region Title Field

            // define title field element
            var titleField = new TextFieldDefinitionElement(mainSection.Fields)
            {
                ID            = "titleFieldControl",
                DataFieldName = displayMode == FieldDisplayMode.Write ? "Title.PersistedValue" : "Title",
                DisplayMode   = displayMode,
                Title         = "Title",
                CssClass      = "sfTitleField",
                WrapperTag    = HtmlTextWriterTag.Li,
            };

            // add validation
            titleField.ValidatorConfig = new ValidatorDefinitionElement(titleField)
            {
                Required                 = true,
                MessageCssClass          = "sfError",
                RequiredViolationMessage = "Title field is required"
            };

            // add field to section
            mainSection.Fields.Add(titleField);

            #endregion

            #region Content

            var contentField = new HtmlFieldElement(mainSection.Fields)
            {
                ID                           = "contentFieldControl",
                DataFieldName                = displayMode == FieldDisplayMode.Write ? "Content.PersistedValue" : "Content",
                DisplayMode                  = displayMode,
                CssClass                     = "sfFormSeparator sfContentField",
                WrapperTag                   = HtmlTextWriterTag.Li,
                EditorContentFilters         = Telerik.Web.UI.EditorFilters.DefaultFilters,
                EditorStripFormattingOptions = (EditorStripFormattingOptions?)(EditorStripFormattingOptions.MSWord | EditorStripFormattingOptions.Css | EditorStripFormattingOptions.Font | EditorStripFormattingOptions.Span | EditorStripFormattingOptions.ConvertWordLists)
            };
            mainSection.Fields.Add(contentField);

            #endregion

            #region Address fields

            // Address field
            var addressField = new TextFieldDefinitionElement(mainSection.Fields)
            {
                ID            = "addressFieldControl",
                DataFieldName = "Address",
                DisplayMode   = displayMode,
                Title         = "Address",
                CssClass      = "sfTitleField",
                WrapperTag    = HtmlTextWriterTag.Li
            };
            addressField.ValidatorConfig = new ValidatorDefinitionElement(addressField)
            {
                Required                 = true,
                MessageCssClass          = "sfError",
                RequiredViolationMessage = "Location address is required"
            };
            mainSection.Fields.Add(addressField);

            // City field
            var cityField = new TextFieldDefinitionElement(mainSection.Fields)
            {
                ID            = "cityFieldControl",
                DataFieldName = "City",
                DisplayMode   = displayMode,
                Title         = "City",
                CssClass      = "sfTitleField",
                WrapperTag    = HtmlTextWriterTag.Li
            };
            mainSection.Fields.Add(cityField);

            // State / Region field
            var regionField = new TextFieldDefinitionElement(mainSection.Fields)
            {
                ID            = "regionFieldControl",
                DataFieldName = "Region",
                DisplayMode   = displayMode,
                Title         = "State / Region",
                CssClass      = "sfTitleField",
                WrapperTag    = HtmlTextWriterTag.Li
            };
            regionField.ValidatorConfig = new ValidatorDefinitionElement(regionField)
            {
                Required                 = true,
                MessageCssClass          = "sfError",
                RequiredViolationMessage = "State / Region is a required field"
            };
            mainSection.Fields.Add(regionField);

            // Postal Code field
            var postalCodeField = new TextFieldDefinitionElement(mainSection.Fields)
            {
                ID            = "postalCodeFieldControl",
                DataFieldName = "PostalCode",
                DisplayMode   = displayMode,
                Title         = "Postal Code",
                CssClass      = "sfTitleField",
                WrapperTag    = HtmlTextWriterTag.Li
            };
            postalCodeField.ValidatorConfig = new ValidatorDefinitionElement(postalCodeField)
            {
                Required                 = true,
                MessageCssClass          = "sfError",
                RequiredViolationMessage = "Postal code is a required field"
            };
            mainSection.Fields.Add(postalCodeField);

            // Country field
            var countryField = new TextFieldDefinitionElement(mainSection.Fields)
            {
                ID            = "countryFieldControl",
                DataFieldName = "Country",
                DisplayMode   = displayMode,
                Title         = "Country",
                CssClass      = "sfTitleField",
                WrapperTag    = HtmlTextWriterTag.Li
            };

            countryField.ValidatorConfig = new ValidatorDefinitionElement(countryField)
            {
                Required                 = true,
                MessageCssClass          = "sfError",
                RequiredViolationMessage = "Country is a required field"
            };

            mainSection.Fields.Add(countryField);

            // add section to view
            detailView.Sections.Add(mainSection);

            #endregion

            #region Categories and Tags Section

            // define new section
            var taxonSection = new ContentViewSectionElement(detailView.Sections)
            {
                Name     = "TaxonSection",
                Title    = "Categories and Tags",
                CssClass = "sfExpandableForm",
                ExpandableDefinitionConfig =
                {
                    Expanded = false
                }
            };

            // add categories field to section
            var categories = DefinitionTemplates.CategoriesFieldWriteMode(taxonSection.Fields);
            categories.DisplayMode = displayMode;

            // add categories section to view
            taxonSection.Fields.Add(categories);

            // add tags field to section
            var tags = DefinitionTemplates.TagsFieldWriteMode(taxonSection.Fields);
            tags.DisplayMode = displayMode;
            tags.CssClass    = "sfFormSeparator";
            tags.ExpandableDefinition.Expanded = true;
            tags.Description = "TagsFieldInstructions";
            taxonSection.Fields.Add(tags);

            // add tags section to view
            detailView.Sections.Add(taxonSection);

            #endregion

            #region More options Section

            // define new section
            var moreOptionsSection = new ContentViewSectionElement(detailView.Sections)
            {
                Name     = "MoreOptionsSection",
                Title    = "More Options",
                CssClass = "sfExpandableForm",
                ExpandableDefinitionConfig =
                {
                    Expanded = false
                }
            };

            // Url field for insert view
            if (displayMode == FieldDisplayMode.Write)
            {
                var urlName = new MirrorTextFieldElement(moreOptionsSection.Fields)
                {
                    Title                   = "URL",
                    ID                      = "urlName",
                    MirroredControlId       = titleField.ID,
                    DataFieldName           = "UrlName.PersistedValue",
                    DisplayMode             = displayMode,
                    RegularExpressionFilter = DefinitionsHelper.UrlRegularExpressionFilter,
                    WrapperTag              = HtmlTextWriterTag.Li,
                    ReplaceWith             = "-"
                };
                var validationDef = new ValidatorDefinitionElement(urlName)
                {
                    Required                          = true,
                    MessageCssClass                   = "sfError",
                    RequiredViolationMessage          = "Url cannot be empty",
                    RegularExpression                 = DefinitionsHelper.UrlRegularExpressionFilterForValidator,
                    RegularExpressionViolationMessage = "Invalid Url"
                };
                urlName.ValidatorConfig = validationDef;

                moreOptionsSection.Fields.Add(urlName);
            }

            // add url section to view
            detailView.Sections.Add(moreOptionsSection);

            #endregion
        }