Bootstrap can show a group of inline checkboxes like this:
<label class="checkbox-inline">
<input type="checkbox" id="inlineCheckbox1" value="option1"> 1
</label>
<label class="checkbox-inline">
<input type="checkbox" id="inlineCheckbox2" value="option2"> 2
</label>
<label class="checkbox-inline">
<input type="checkbox" id="inlineCheckbox3" value="option3"> 3
</label>
Now suppose that these checkboxes must come from an enum in my viewmodel. So for example I have HolidayModel.RoomPrefs
which is an enum like this:
[Flags]
enum ReservationPreferences {
Room = 2,
Breakfast = 4,
Lunch = 8,
Dinner = 16
}
I want to render this enum as a group of inline checkboxes (i.e. the markup above).
I can do so manually, but I rather use a helper or editor template, or something else generic, because the HolidayModel
viewmodel has other enums and so I want to reuse the code.
Does Razor have something out of the box to support this?