Deane
Deane

Reputation: 8747

Why doesn't Web Forms for Marketers correctly populate the selected DropList value in my custom save action?

Inside my custom save action, I iterate through the form fields (the AdaptedControlResult objects). Any form field which is a DropList (from any source -- manually entered values, or an item lookup) is returning a string value of System.Collections.Generic.List`1[System.String]

Now, it's important to know, it's not returning an actual List. It's returning a literal string with that value.

So, this call:

fields.GetEntryByName("MyFieldName").Value

Is returning the string: System.Collections.Generic.List`1[System.String]. Not the value of the dropdown. A string saying that's it's a List<string>.

I have confirmed the HTML of the form is rendering correctly. I have manually checked the inbound HttpContext.Current.Request.Form values as well...

HttpContext.Current.Request.Form["BGWnjkQqrE6w6sr31IgzrQ.Sections[5].Fields[0].Value"]

That is the correctly-selected value of the drop down (a Sitecore ID).

So, the data is getting output to the form correctly, and the inbound Request.Form data is also correct. Somewhere, Sitecore is deciding not to populate the selected value into the AdaptedControlResult object.

What's additionally odd is that for DropList field types, the selected value does appear in the Parameters property (inexplicably). I would just detect this and use it, but it's not consistent -- for instance, for textbox field types, the word "multiline" appears there.

All other field types work fine -- I have several text entry fields, and some radio button lists. It's just DropList fields.

What is the trick to getting this?

Upvotes: 3

Views: 1011

Answers (1)

jammykam
jammykam

Reputation: 16990

This is a known bug in Sitecore when using the WFFM module in MVC. You can find more details in this Knowledge Base Article - Incorrect data is saved for list fields in WFFM MVC.

The fix is listed on the kb article and depends on the exact version of Sitecore you are using. Sorry to provided a link only answer but there are multiple steps reqiured for the fix and the download for the fix is attached in the article.

Upvotes: 5

Related Questions