And finally in my View i could do this in the BeginUmbracoForm:
@* specialisms need to list specialisms as check boxes here*@<divclass="form-group">@for (int i = 0; i < Model.AllSpecialism.Count; i++)
{
@Html.CheckBoxFor(m => m.AllSpecialism[i].Selected, new { id = "specialismType_" + i })
@Html.HiddenFor(m => m.AllSpecialism[i].Name)
@Html.DisplayFor(m => m.AllSpecialism[i].Name)
}
@Html.ValidationMessageFor(model => model.AllSpecialism, string.Empty, new { @class= "" })
</div>
yeh i have tweaked it a little, and pretty much have the same as you have now as i needed the Pre Value to assign the correct option in the Checkbox list DataType.
Best way to deal with mulitple checkboxes in BeginUmbracoForm
Hi
Using MVC Umbraco 6.1.6
Still finding my feet with MVC and wanted to ask the best way to deal with multiple checkboes in a BeginUmbracoForm. What i have so far:
The View
Model:
Think im not too far away from it, just confused where i can add the list of Specialisms, does this need to be added in the Model?
Any help greatly appreciated.
Ok think ive sussed this myself, here is what i did just in case anyone else needs to do the same
in my Model i added this:
And then in my Surface Controller i added the following:
And finally in my View i could do this in the BeginUmbracoForm:
Hopefully this will work Ok :)
Excellent, thanks a lot. That really helped! For me, I needed to persist names and values across so I used...
This seems to be working, but if a better way is there, I'd be very interested to hear it.
Hi Simon
Glad it helped,
yeh i have tweaked it a little, and pretty much have the same as you have now as i needed the Pre Value to assign the correct option in the Checkbox list DataType.
I did however have another thread where some other options were presented but not had time to go over them properly, here is the thread, may help you some more - http://our.umbraco.org/forum/developers/api-questions/53769-Members-in-v616-handling-checkbox-list-data-type-in-members-properties
Cheers
Neil.
is working on a reply...