Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Josh Olson 79 posts 207 karma points
    Sep 13, 2013 @ 08:34
    Josh Olson
    0

    Duplicate field caption - not in codefirst forms

    The issues that I have encountered is that when designing a form in the backend through the Contour GUI, I can create fields with the same caption (this is desirous behavior), but if I create the same form in Visual Studio using codefirst design, when I try to view the form in the backend or frontend, the form explodes resulting in a

    Exception Details: System.ArgumentException: An item with the same key has already been added.

    and the following stack trace

    [ArgumentException: An item with the same key has already been added.]
       System.ThrowHelper.ThrowArgumentException(ExceptionResource resource) +52
       System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add) +10695474
       System.Collections.Generic.Dictionary`2.Add(TKey key, TValue value) +10
       Umbraco.Forms.CodeFirst.FormManager.SynchronizeForm(Type typeForm) in c:\Program Files (x86)\teamcity\buildAgent\work\fdc2f0fcbbcef310\Umbraco.Forms.CodeFirst\FormBuilder\FormManager.cs:249
       Umbraco.Forms.CodeFirst.FormManager.SynchronizeForms() in c:\Program Files (x86)\teamcity\buildAgent\work\fdc2f0fcbbcef310\Umbraco.Forms.CodeFirst\FormBuilder\FormManager.cs:201
       Umbraco.Forms.CodeFirst.FormManager.Synchronize() in c:\Program Files (x86)\teamcity\buildAgent\work\fdc2f0fcbbcef310\Umbraco.Forms.CodeFirst\FormBuilder\FormManager.cs:24
       Umbraco.Forms.CodeFirst.UmbracoManager.Synchronize() in c:\Program Files (x86)\teamcity\buildAgent\work\fdc2f0fcbbcef310\Umbraco.Forms.CodeFirst\UmbracoManager.cs:36
       Umbraco.Forms.CodeFirst.UmbracoManager.SynchronizeIfNotSynchronized() in c:\Program Files (x86)\teamcity\buildAgent\work\fdc2f0fcbbcef310\Umbraco.Forms.CodeFirst\UmbracoManager.cs:21
       Umbraco.Forms.CodeFirst.ContourFormBuilderHttpModule.context_BeginRequest(Object sender, EventArgs e) in c:\Program Files (x86)\teamcity\buildAgent\work\fdc2f0fcbbcef310\Umbraco.Forms.CodeFirst\ContourFormBuilderHttpModule.cs:27
       System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +136
       System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +69
    

    I would like to be able to have fields with the same caption but designing forms in the GUI editor is tedious except for the most simple of cases. Any pointers would greatly appreciated!

    Umbraco: 6.1.3 --- Contour: 3.0.14

    Cheers!

  • Kenny Burns 165 posts 285 karma points
    Nov 21, 2013 @ 12:58
    Kenny Burns
    0

    I am also having the same issues as outlined above - did anyone manage to solve this?

    Thanks,

    Kenny

  • Tim Geyssens 6419 posts 15052 karma points MVP 2x c-trib
    Nov 21, 2013 @ 12:59
    Tim Geyssens
    0

    I'll test, mind posting the code for the form that is giving this error?

  • Kenny Burns 165 posts 285 karma points
    Nov 21, 2013 @ 13:07
    Kenny Burns
    0

    Hey Tim,

    Thanks for the help -

    [Form("Questionnaire", ShowValidationSummary = true, MessageOnSubmit = "Thank you for your submission.")]

            public class QuestionnaireForm : FormBase

            {

     [Field(FormPages.Questionnaire, "Quality", Caption = "How is our performance?",

                    Type = typeof (RadioButtonList),

                    Prevalues = new[] {"1", "2", "3", "4", "5"},

                    Mandatory = true)]

               public string PerformanceProductQuality { get; set; }

    .....(other fields)

    [Field(FormPages.Questionnaire, "Quality", Caption = "How is our performance?",

                   Type = typeof (RadioButtonList),

                 Prevalues = new[] {"1", "2", "3", "4", "5"},

                   Mandatory = true)]

               public string PerformanceProductLabelling { get; set; }

    }

    It seems to be if the caption is the same, it throws the error - it works okay from back office.

    Thanks,

    Kenny

     

  • Tim Geyssens 6419 posts 15052 karma points MVP 2x c-trib
    Nov 21, 2013 @ 13:11
    Tim Geyssens
    1

    Ok thanks will give it a test and will probably have a solution for you in the afternoon! stay tuned ;)

  • Tim Geyssens 6419 posts 15052 karma points MVP 2x c-trib
    Nov 21, 2013 @ 15:43
    Tim Geyssens
    1

    Can confirm it's a bug but need some more testing before i can push a release, eta tomorrow morning, hope that's ok

  • Kenny Burns 165 posts 285 karma points
    Nov 21, 2013 @ 16:44
    Kenny Burns
    0

    That would be great Tim - thanks very much for looking at so quickly, much appreciated.

    Kenny

  • Tim Geyssens 6419 posts 15052 karma points MVP 2x c-trib
    Nov 22, 2013 @ 09:58
    Tim Geyssens
    0

    Finishing it first thing this morning so solution almost ready :)

  • Tim Geyssens 6419 posts 15052 karma points MVP 2x c-trib
    Nov 22, 2013 @ 10:23
    Tim Geyssens
    0

    Aight fixed the error

    But since in the code first a couple of things happen based on the caption it might not be that ideal to have duplicates :)

    To upgrade just download http://nightly.umbraco.org/Umbraco%20Contour/3.0.18%20WIP/

    The update zip UmbracoContour3.0.18 WIPupdate.zip

    only thing you need when running on 3.0.17 is the codefirst assembly, drop that in your bin and the error should be gone

  • Kenny Burns 165 posts 285 karma points
    Nov 22, 2013 @ 11:00
    Kenny Burns
    0

    Hey Tim,

    Thanks for looking at this - I grabbed the zip and dropped the Umbraco.Forms.CodeFirst.dll into the bin but that still didn't seem to  fix the issue - I notice the assembly version still says 3.0.17.0?

    Kenny

     

  • Tim Geyssens 6419 posts 15052 karma points MVP 2x c-trib
    Nov 22, 2013 @ 11:03
  • Kenny Burns 165 posts 285 karma points
    Nov 22, 2013 @ 11:17
    Kenny Burns
    0

    Hmm - still getting the error - if the below helps? Should the assembly version be 3.0.18? Still says 3.0.17 (although that might not be the issue)

    Thanks

    [ArgumentException: An item with the same key has already been added.]
       System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add) +14119204
       Umbraco.Forms.CodeFirst.FormManager.SynchronizeForm(Type typeForm) in c:\Users\Timbo\Dropbox\Umbraco\Contour\Umbraco.Forms.CodeFirst\FormBuilder\FormManager.cs:333
       Umbraco.Forms.CodeFirst.FormManager.SynchronizeForms() in c:\Users\Timbo\Dropbox\Umbraco\Contour\Umbraco.Forms.CodeFirst\FormBuilder\FormManager.cs:201
       Umbraco.Forms.CodeFirst.FormManager.Synchronize() in c:\Users\Timbo\Dropbox\Umbraco\Contour\Umbraco.Forms.CodeFirst\FormBuilder\FormManager.cs:24
       Umbraco.Forms.CodeFirst.UmbracoManager.Synchronize() in c:\Users\Timbo\Dropbox\Umbraco\Contour\Umbraco.Forms.CodeFirst\UmbracoManager.cs:36
       Umbraco.Forms.CodeFirst.UmbracoManager.SynchronizeIfNotSynchronized() in c:\Users\Timbo\Dropbox\Umbraco\Contour\Umbraco.Forms.CodeFirst\UmbracoManager.cs:21
       Umbraco.Forms.CodeFirst.ContourFormBuilderHttpModule.context_BeginRequest(Object sender, EventArgs e) in c:\Users\Timbo\Dropbox\Umbraco\Contour\Umbraco.Forms.CodeFirst\ContourFormBuilderHttpModule.cs:27
       System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +80 

    System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +165 

  • Tim Geyssens 6419 posts 15052 karma points MVP 2x c-trib
    Nov 22, 2013 @ 11:23
    Tim Geyssens
    0

    Yeah haven't updated assembly version, but the stack trace helps, looking now :)

  • Tim Geyssens 6419 posts 15052 karma points MVP 2x c-trib
    Nov 22, 2013 @ 11:30
    Tim Geyssens
    0

    Of seems you get an error I didn't get when testing but fixed now, please download the nightly again :)

    Again it's just the code first stuff that needs to be updated

  • Kenny Burns 165 posts 285 karma points
    Nov 22, 2013 @ 11:56
    Kenny Burns
    0

    I have downloaded the nightly and this seems to work - gets rid of the error - but still not working as expected :(

    It doesnt create the additional fields that have the same caption, not sure if that was expected or not. i.e. it creates the first field but any subsequent fields that have the same caption (in this case there are the same questions in multiple fieldsets) are not created.

    I can leave this with you for a bit if you think there is a fix for it? If you can let me know so I can schedule work around it.

    Thanks again - *sorry for causing you grief on a Friday morning! :)

  • Tim Geyssens 6419 posts 15052 karma points MVP 2x c-trib
    Nov 22, 2013 @ 11:57
    Tim Geyssens
    0

    Yeah will need some serious refactor in that case since a lot is based on the field caption, maybe if they are on a different fieldset... could you give that a try?

  • Tim Geyssens 6419 posts 15052 karma points MVP 2x c-trib
    Nov 22, 2013 @ 11:58
    Tim Geyssens
    0

    Or as a workaround use dictionary items and and populate them with the same value, that's the best I can think of atm

    SO #quality1 #quality2 ... but all have the same value

  • Kenny Burns 165 posts 285 karma points
    Nov 22, 2013 @ 12:09
    Kenny Burns
    0

    Thanks Tim - I will try the dictionary item suggestion - that should do as a workaround. The different fieldsets is still causing the same issue i'm afraid.

    Appreciate you looking into it for us,

    Have a good one :)

    Kenny

  • Tim Geyssens 6419 posts 15052 karma points MVP 2x c-trib
    Nov 22, 2013 @ 12:17
    Tim Geyssens
    0

    Yeah the dictionary item workaround should do it then :)

  • Kenny Burns 165 posts 285 karma points
    Nov 22, 2013 @ 12:47
    Kenny Burns
    0

    I can confirm the dictionary items work just grand! Cheers! 

    (I also reverted my dlls back to the older version)

  • Tim Geyssens 6419 posts 15052 karma points MVP 2x c-trib
    Nov 22, 2013 @ 13:04
    Tim Geyssens
    0

    Great :) hope that's a valid solution for the time being!

Please Sign in or register to post replies

Write your reply to:

Draft