DmitryEfimenko / TwitterBootstrapMvc

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

RadioButtonsFromEnum #346

Closed vanithav closed 9 years ago

vanithav commented 9 years ago

Am using this and am getting the radio buttons correctly. However the value property has the name of the enum instead of the enum value. How to assign the enum value under the value property of radiobutton?

@(f.FormGroup().RadioButtonsFromEnum<MyEnumType>("Placement")) 

and how do i set the selected value for this?

Thanks, Vanitha.

DmitryEfimenko commented 9 years ago

I don't think you need to set the value property to the enum value because it'll bind model just fine with that. If you really want that though for some reason that I do not know of, check out docs for RadioButtonsEnum. You may find extension .InputHtmlAttributes() useful.

The radio button will become selected based on the model property value. So set your Model.Placement and corresponding radio button will be selected.

vanithav commented 9 years ago

Thanks for the help. It was my mistake. I had declared it as int instead on Enum in my model and hence the issue. Now everything works fine.