Codefirst form error "Sequence contains no matching element", multiple fields in db
Hi,
My setup is:
Umbraco 7.1.6
Contour 3.0.23
I'm trying to build a codefirst form that contains conditions. I'll post the code below. When I build and run the site I get the following error:
Sequence contains no matching element
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidOperationException: Sequence contains no matching element
Stack Trace:
[InvalidOperationException: Sequence contains no matching element]
System.Linq.Enumerable.Single(IEnumerable`1 source, Func`2 predicate) +2614017
Umbraco.Forms.CodeFirst.FormManager.SynchronizeForm(Type typeForm) in f:\TeamCity\buildAgent\work\3b0e3c3a4846294b\Umbraco.Forms.CodeFirst\FormBuilder\FormManager.cs:501
Umbraco.Forms.CodeFirst.FormManager.SynchronizeForms() in f:\TeamCity\buildAgent\work\3b0e3c3a4846294b\Umbraco.Forms.CodeFirst\FormBuilder\FormManager.cs:201
Umbraco.Forms.CodeFirst.FormManager.Synchronize() in f:\TeamCity\buildAgent\work\3b0e3c3a4846294b\Umbraco.Forms.CodeFirst\FormBuilder\FormManager.cs:24
Umbraco.Forms.CodeFirst.UmbracoManager.Synchronize() in f:\TeamCity\buildAgent\work\3b0e3c3a4846294b\Umbraco.Forms.CodeFirst\UmbracoManager.cs:36
Umbraco.Forms.CodeFirst.UmbracoManager.SynchronizeIfNotSynchronized() in f:\TeamCity\buildAgent\work\3b0e3c3a4846294b\Umbraco.Forms.CodeFirst\UmbracoManager.cs:21
Umbraco.Forms.CodeFirst.ContourFormBuilderHttpModule.context_BeginRequest(Object sender, EventArgs e) in f:\TeamCity\buildAgent\work\3b0e3c3a4846294b\Umbraco.Forms.CodeFirst\ContourFormBuilderHttpModule.cs:27
System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +136
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +69
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.34237
When I look in the database (SqlCE) I see that the table UFFieldsets has duplicate entries for my form's fieldset. And the table UFFields has duplicate entries for each of the form's fields.
What is going on and how can I fix it?
Here is my codefirst form:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Umbraco.Forms.CodeFirst;
using Umbraco.Forms.Core;
using Umbraco.Forms.Core.Providers;
using Umbraco.Forms.Core.Providers.FieldTypes;
namespace WebApplication1.App_Code.AM.SteppedForm
{
[Form("SteppedForm", Id = "59d7c262-76b4-40be-bf10-fc1a4995376b",
ShowValidationSummary = true,
MessageOnSubmit = "Thank You!")]
public class SteppedForm : FormBase
{
[Field("ContactILA", "MemberStatus",
Caption = "Are you a current member?",
Mandatory = true,
RequiredErrorMessage = "Are you a current member?",
Type = typeof(RadioButtonList),
Prevalues = new string[2] { "Yes", "No" })]
public string IsMember { get; set; }
[Field("ContactILA", "MemberStatus",
Caption = "Are you interested in membership?",
Type = typeof(RadioButtonList),
Prevalues = new string[2] { "Yes", "No" },
EnableCondition = true,
ConditionActionType = FieldConditionActionType.Show,
ConditionLogicType = FieldConditionLogicType.Any)]
[FieldConditionRule("IsMember", FieldConditionRuleOperator.Is, "No")]
public string MembershipInterest { get; set; }
[Field("ContactILA", "MemberStatus",
Caption = "Member Number",
EnableCondition = true,
ConditionActionType = FieldConditionActionType.Show,
ConditionLogicType = FieldConditionLogicType.Any)]
[FieldConditionRule("IsMember", FieldConditionRuleOperator.Is, "Yes")]
public string MemberNumber { get; set; }
public override IEnumerable<Exception> Validate()
{
var e = new List<Exception>();
if (this.IsMember == "Yes" && string.IsNullOrEmpty(this.MemberNumber))
{
e.Add(new Exception("Please enter your member number."));
}
return e;
}
}
}
@Dennis ... Thank you for the suggestion. In that thread the OP has the same problem that I do but then he later states that he fixed it but doesn't say how. I suppose I will contact the OP directly and see if he'll be willing to share info. I'll post back here with my results.
@Dennis ... Thanks. I actually started this whole process by reading Tim's nibble.be posts. Unfortunately, I haven't found a discussion around this particular issue there.
I'm thinking the problem is with the conditional logic attributes I've attached to my class properties so I decided to build a Contour form with conditional logic using the UI to see how it works.
Again, a clean Umbraco 7.1.6 site with Contour 3.0.23 (the latest release). I log into the backoffice and in the Contour section I create a form with three fields:
1) Are you a member? ... radio button list with two prevalues: "Yes" and "No". Marked as mandatory.
2) Member Number ... textfield. Conditional logic: If "Are you a member?" == "Yes" then show this field. Not mandatory.
3) Are you interested in membership? ... radio button list with two prevalues: "Yes" and "No". Not mandatory. Conditional logic: If "Are you a member?" == "No" then show this field.
I had to make sure my template had the following script tags (which isn't mentioned anywhere in the documentation that I can find):
Then I inserted the form into an RTE field using the insert razor macro tool. Loaded up my page in Google Chrome and ... nothing. The conditional logic doesn't work. No javascript errors.
Now, granted I'm not using the latest and greatest Umbraco version, but still ...
Codefirst form error "Sequence contains no matching element", multiple fields in db
Hi,
My setup is:
I'm trying to build a codefirst form that contains conditions. I'll post the code below. When I build and run the site I get the following error:
When I look in the database (SqlCE) I see that the table UFFieldsets has duplicate entries for my form's fieldset. And the table UFFields has duplicate entries for each of the form's fields.
What is going on and how can I fix it?
Here is my codefirst form:
Thanks!
chester
Hi Chester,
Perhaps this post can help you to get back on track again. http://our.umbraco.org/forum/umbraco-pro/contour/54843-Creating-form-with-code-first-and-conditional-logic
Hope this helps,
/Dennis
@Dennis ... Thank you for the suggestion. In that thread the OP has the same problem that I do but then he later states that he fixed it but doesn't say how. I suppose I will contact the OP directly and see if he'll be willing to share info. I'll post back here with my results.
Okay, I just found a blogpost on TimĀ“s blog perhaps you can get closer to a solution looking at this http://www.nibble.be/?p=205
/Dennis
@Dennis ... Thanks. I actually started this whole process by reading Tim's nibble.be posts. Unfortunately, I haven't found a discussion around this particular issue there.
I'm thinking the problem is with the conditional logic attributes I've attached to my class properties so I decided to build a Contour form with conditional logic using the UI to see how it works.
Again, a clean Umbraco 7.1.6 site with Contour 3.0.23 (the latest release). I log into the backoffice and in the Contour section I create a form with three fields:
1) Are you a member? ... radio button list with two prevalues: "Yes" and "No". Marked as mandatory.
2) Member Number ... textfield. Conditional logic: If "Are you a member?" == "Yes" then show this field. Not mandatory.
3) Are you interested in membership? ... radio button list with two prevalues: "Yes" and "No". Not mandatory. Conditional logic: If "Are you a member?" == "No" then show this field.
I had to make sure my template had the following script tags (which isn't mentioned anywhere in the documentation that I can find):
Then I inserted the form into an RTE field using the insert razor macro tool. Loaded up my page in Google Chrome and ... nothing. The conditional logic doesn't work. No javascript errors.
Now, granted I'm not using the latest and greatest Umbraco version, but still ...
is working on a reply...