DmitryEfimenko / TwitterBootstrapMvc

Fluent implementation of ASP.NET-MVC HTML helpers for Twitter Bootstrap.
Apache License 2.0
222 stars 79 forks source link

Enum Dropdown List #126

Closed chrisjainsley closed 10 years ago

chrisjainsley commented 10 years ago

An enum drop-down list would be handy, similar to RadioButtonsFromEnum and RadioButtonsFromEnumFor.

DmitryEfimenko commented 10 years ago

I had this in mind for a while already. Just was waiting for somebody to ask :)

angelocarlotto commented 10 years ago

Awesome!!! I would like to have it as well! =]

Thanks!!

DmitryEfimenko commented 10 years ago

This is finally in the new version of BMVC. Sorry it took so long.

j-walker23 commented 10 years ago

I was hoping you would have this, thanks. I just updated to 3.7.2 but i can't find a dropdown enum in the dll. How can i use this new feature?

DmitryEfimenko commented 10 years ago

I'll soon update docs for this. Meanwhile, here is a quick code snippets. Enum:

public enum Color
{
    Red = 1,
    Green = 2,
    Blue = 3,
    Yellow = 4
}

In the View Model:

public Color Color { get; set; }

In the View:

@f.FormGroup().DropDownListFromEnumFor(x => x.Color)

Check out extension methods on it also. They are similar extension methods used on other inputs.

j-walker23 commented 10 years ago

I haven't had a chance to try it yet, but thanks again for the quick response, as always!