Copied to clipboard

Flag this post as spam?

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


  • Simon Napper 50 posts 159 karma points
    Apr 12, 2013 @ 12:49
    Simon Napper
    0

    Codefirst CheckBoxList and prevalues seem to need a comma in the array element?

    Hi all,

    I came across a strange problem the other day that I'm hoping is something that I've missed rather than a bug in Contour, so perhaps one of you lovely people could let me know!  I'm creating a checkboxlist on a codefirst contour page, however I found that if I don't have a comma within the value entered into the array for the prevalues, that I get a:

    Object of type 'System.String' cannot be converted to type 'System.Collections.Generic.List`1[System.String]'

    error, however if I add a comma to the text in the array it works fine.  To show you what I mean, the first code block below causes the error:

    [Field(FormPages.Callout,
                   FormFieldsets.Signup, 
                   Type = typeof(CheckBoxList),
                   Prevalues = new[] { "Yes", "No" })]
            public List<string> Member { get; set; }

    However this one is fine, notice the addition of an extra comma after Yes and No:

    [Field(FormPages.Callout,
                   FormFieldsets.Signup, 
                   Type = typeof(CheckBoxList),
                   Prevalues = new[] { "Yes,", "No," })]
            public List<string> Member { get; set; }

     

    Anyone able to shed some light on this or suggest an alternative approach?

    Many Thanks.

  • Tim Geyssens 6562 posts 15373 karma points MVP 2x c-trib
    Apr 15, 2013 @ 09:59
    Tim Geyssens
    0

    Hmm that's strange, will give it a try

  • Tim Geyssens 6562 posts 15373 karma points MVP 2x c-trib
    Apr 15, 2013 @ 10:08
    Tim Geyssens
    0

    Hi Simon,

    Just tested and it should work without the extra comma

    When exactly are you getting the error, could you post a stacktrace

    I tried created a new form code first with your example and that works...

  • Simon Napper 50 posts 159 karma points
    Apr 15, 2013 @ 17:02
    Simon Napper
    0

    Hi Tim,

    Thanks for getting back so promptly.  Here's the stacktrace from the detail of the exception, if you need anything else then please feel free to ask!

     

       at System.RuntimeType.TryChangeType(Object value, Binder binder, CultureInfo culture, Boolean needsSpecialCast)

      at System.Reflection.MethodBase.CheckArguments(Object[] parameters, Binder binder, BindingFlags invokeAttr, CultureInfo culture, Signature sig)

       at System.Reflection.RuntimeMethodInfo.InvokeArgumentsCheck(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)

       at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)

       at System.Reflection.RuntimePropertyInfo.SetValue(Object obj, Object value, Object[] index)

       at Umbraco.Forms.CodeFirst.FormManager.CreateFormBaseInstance(FormViewEventArgs e) in c:\Program Files (x86)\teamcity\buildAgent\work\fdc2f0fcbbcef310\Umbraco.Forms.CodeFirst\FormBuilder\FormManager.cs:line 187

       at Umbraco.Forms.CodeFirst.FormManager.FormRenderController_FormValidate(Object sender, FormViewEventArgs e) in c:\Program Files (x86)\teamcity\buildAgent\work\fdc2f0fcbbcef310\Umbraco.Forms.CodeFirst\FormBuilder\FormManager.cs:line 33

       at Umbraco.Forms.Mvc.Controllers.FormRenderController.ContourForm(FormViewModel model, Boolean captchaIsValid) in c:\Program Files (x86)\teamcity\buildAgent\work\fdc2f0fcbbcef310\Umbraco.Forms.Mvc\Controllers\FormRenderController.cs:line 178

       at lambda_method(Closure , ControllerBase , Object[] )

       at System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters)

       at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters)

       at System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClass13.<InvokeActionMethodWithFilters>b__10()

       at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation)

     

    Thanks in advance!

    Simon

     

  • Tim Geyssens 6562 posts 15373 karma points MVP 2x c-trib
    Apr 15, 2013 @ 17:16
    Tim Geyssens
    0

    Looks like it is happening in the validate method, so might be a bug there, checking it out now

  • Tim Geyssens 6562 posts 15373 karma points MVP 2x c-trib
    Apr 15, 2013 @ 17:20
    Tim Geyssens
    0

    Ok can confirm that it's a bug, happens when you only select 1 item in the checkboxlist

     

  • Tim Geyssens 6562 posts 15373 karma points MVP 2x c-trib
    Apr 15, 2013 @ 17:21
    Tim Geyssens
    0

    Added to our issue tracker http://issues.umbraco.org/issue/CON-331 will try to have a fix this week

  • Simon Napper 50 posts 159 karma points
    Apr 15, 2013 @ 17:26
    Simon Napper
    0

    Thanks Tim, will keep my eyes peeled for the fix!

  • Tim Geyssens 6562 posts 15373 karma points MVP 2x c-trib
    Apr 15, 2013 @ 17:34
    Tim Geyssens
    100

    Ok think I found a fix :)

    Could you try downloading http://nightly.umbraco.org/Umbraco%20Contour/3.0.10%20WIP/

    UmbracoContour_3.0.10 WIP_update.zip

    And you'll just need to deploy Umbraco.Forms.CodeFirst.dll to your bin directory

    Let me know if that fixes the issue for you

    Cheers,
    Tim 

  • Simon Napper 50 posts 159 karma points
    Apr 16, 2013 @ 15:18
    Simon Napper
    0

    Hi Tim,

    That's perfect, works like a treat now!  Thanks for your help with this.

    Cheers,

    Simon

  • Tim Geyssens 6562 posts 15373 karma points MVP 2x c-trib
    Apr 16, 2013 @ 16:14
    Tim Geyssens
    0

    Great, thanks for confirming!

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies