AllowComments field appears 3 times
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);
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
Hi Daniel,
Can you past the moreOptionsSection and all definition elements in it?
All the best,
Ivan Dimitrov
the Telerik team
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
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);
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,