If you take a look at the code you are using from that post it uses the publicoverrideSystem.Web.UI.WebControls.WebControlEditor and that is only used with the usercontrol macro, the razor one doesn't use that webcontrol
What you can do is just write the loop in your razor view so replace
@foreach (var pv in Model.PreValues)
with a loop of countries CultureInfo.GetCultures(CultureTypes.SpecificCultures);
Custom field type in razor
Guys,
I have created a custom field type country picker using http://our.umbraco.org/forum/umbraco-pro/contour/27135-country-picker-in-Contour?p=0 I am using contour razor macro. I need to render out the country list as a drop down list but not sure how todo this. Any ideas?
Looking at the code for dropdown list in FieldType.DropDownList.cshtml we have
@model Umbraco.Forms.Mvc.Models.FieldViewModel
<select name="@Model.Name" id="@Model.Id"
@if (Model.Mandatory){<text> data-val="true" data-val-required="@Model.RequiredErrorMessage"</text>}
>
<option value=""></option>
@foreach (var pv in Model.PreValues)
{
<option value="@pv.Value"
@if (Model.ContainsValue(pv.Value))
{<text>selected="selected"</text>}
>@pv.Value</option>
}
</select>
However this does not render anything am i missing something? Also in the backend the llist should be populated as well? Currently its not ?
Regards
Ismail
Comment author was deleted
Hey Ismail,
If you take a look at the code you are using from that post it uses the publicoverrideSystem.Web.UI.WebControls.WebControlEditor and that is only used with the usercontrol macro, the razor one doesn't use that webcontrol
What you can do is just write the loop in your razor view so replace
@foreach (var pv in Model.PreValues)
with a loop of countries CultureInfo.GetCultures(CultureTypes.SpecificCultures);
Comment author was deleted
Or you could also use this prevalue source instead bonus is that that one is multilingual :) http://www.nibble.be/?p=217
Comment author was deleted
This post has an example of a razor only fieldtype
http://our.umbraco.org/forum/umbraco-pro/contour/40417-Creating-custom-FieldType-with-multiple-SingleLine-textboxes
is working on a reply...