AllowComments field appears 3 times

Posted by Community Admin on 04-Aug-2018 15:41

AllowComments field appears 3 times

All Replies

Posted by Community Admin on 03-Jun-2011 00:00

Hi,

I changed the productsmodule to serve as  a companymodule.
All worked fine, until I started to create resources for the dutch language.

I got some errors on not to add multiple items in a SingeCheckBox item.
Now the insert/edit screen is working again (for some reason??) and I see 3 times the 'AllowComments' checkbox.

This is the code for adding this box:

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(CompaniesResources).Name
           ;
           allowCommentsFieldElement.ChoicesConfig.Add(
               new ChoiceElement(allowCommentsFieldElement.ChoicesConfig)
                   Text = Res.Get(typeof(CompaniesResources).Name, "AllowComments")
               );
           moreOptionsSection.Fields.Add(allowCommentsFieldElement);
 
           detailView.Sections.Add(moreOptionsSection);

See screenshot for the result.

Regards,
Daniel

Posted by Community Admin on 06-Jun-2011 00:00

I'm getting the same error when I add a custom field to the blogsmodule. I added a field that is a Yes / No (boolean).
The error is below:

01.[ArgumentException: When RenderChoiceAs is set to SingleCheckBox, there should be only one ChoiceItem in the collection]
02.   Telerik.Sitefinity.Web.UI.Fields.ChoiceField.InitializeControls(GenericContainer container) +632
03.   Telerik.Sitefinity.Web.UI.SimpleView.CreateChildControls() +58
04.   System.Web.UI.Control.EnsureChildControls() +102
05.   System.Web.UI.Control.PreRenderRecursiveInternal() +42
06.   System.Web.UI.Control.PreRenderRecursiveInternal() +175
07.   System.Web.UI.Control.PreRenderRecursiveInternal() +175
08.   System.Web.UI.Control.PreRenderRecursiveInternal() +175
09.   System.Web.UI.Control.PreRenderRecursiveInternal() +175
10.   System.Web.UI.Control.PreRenderRecursiveInternal() +175
11.   System.Web.UI.Control.PreRenderRecursiveInternal() +175
12.   System.Web.UI.Control.PreRenderRecursiveInternal() +175
13.   System.Web.UI.Control.PreRenderRecursiveInternal() +175
14.   System.Web.UI.Control.PreRenderRecursiveInternal() +175
15.   System.Web.UI.Control.PreRenderRecursiveInternal() +175
16.   System.Web.UI.Control.PreRenderRecursiveInternal() +175
17.   System.Web.UI.Control.PreRenderRecursiveInternal() +175
18.   System.Web.UI.Control.PreRenderRecursiveInternal() +175
19.   System.Web.UI.Control.PreRenderRecursiveInternal() +175
20.   System.Web.UI.Control.PreRenderRecursiveInternal() +175
21.   System.Web.UI.Control.PreRenderRecursiveInternal() +175
22.   System.Web.UI.Control.PreRenderRecursiveInternal() +175
23.   System.Web.UI.Control.PreRenderRecursiveInternal() +175
24.   System.Web.UI.Control.PreRenderRecursiveInternal() +175
25.   System.Web.UI.Control.PreRenderRecursiveInternal() +175
26.   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2496

Posted by Community Admin on 06-Jun-2011 00:00

Hi Daniel,

Can you past the moreOptionsSection and all definition elements in it?


All the best,
Ivan Dimitrov
the Telerik team

Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 06-Jun-2011 00:00

Hi,

Because I'm not having much time to dive deep into the problems I'm facing (unfortunately) I recreated the project. I see now that the 'AllowComments' is appearing one time in my custom module.

Anyway, this is the code for the moreOptions section

#region More options section
 
            var moreOptionsSection = new ContentViewSectionElement(detailView.Sections)
                Name = "MoreOptionsSection",
                Title = "MoreOptionsURL",
                ResourceClassId = typeof(CompaniesResources).Name,
                CssClass = "sfExpandableForm",
                ExpandableDefinitionConfig =
                    Expanded = false
                
            ;
 
            if (displayMode == FieldDisplayMode.Write)
                var urlName = new MirrorTextFieldElement(moreOptionsSection.Fields)
                    Title = Res.Get<CompaniesResources>().UrlName,
                    ID = "urlName",
                    MirroredControlId = titleField.ID,
                    DataFieldName = "UrlName",
                    DisplayMode = displayMode,
                    RegularExpressionFilter = DefinitionsHelper.UrlRegularExpressionFilter,
                    WrapperTag = HtmlTextWriterTag.Li,
                    ReplaceWith = "-"
                ;
                var validationDef = new ValidatorDefinitionElement(urlName)
                    Required = true,
                    MessageCssClass = "sfError",
                    RequiredViolationMessage = Res.Get<CompaniesResources>().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(CompaniesResources).Name
            ;
            allowCommentsFieldElement.ChoicesConfig.Add(
                new ChoiceElement(allowCommentsFieldElement.ChoicesConfig)
                    Text = Res.Get(typeof(CompaniesResources).Name, "AllowComments")
                );
            moreOptionsSection.Fields.Add(allowCommentsFieldElement);
 
            detailView.Sections.Add(moreOptionsSection);
 
            #endregion


On the other hand I added a new field on the blogsmodule (boolean field), but that fields doesn't appear inside the insert/edit screen??

Regards,
Daniel

Posted by Community Admin on 06-Jun-2011 00:00

Hi Daniel ,

Here is the default configuration that we use for news

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

and in all other modules. There must be something in your module that breaks the way that the ChoiceField is rendered and showed.

Greetings,
Ivan Dimitrov
the Telerik team
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 06-Jun-2011 00:00

Thanks.
I noticed that I didn't have the 'FieldName' property set. I cannot test it yet, since I did not yet enabled multiple languages.

I'll let you know if the problems remains.

Regards,

Daniel

This thread is closed