Question

I am trying to work with enums as properies in my models, as decribed in this Castle Monorail page But I am having some problems when populating a a radio button with that property.

I am using this nvelocity syntax in my view:

$formHelper.RadioField("myModel.MyEnumProperty", 1, "%{}")

(being 1 the integer value for the enum, and also the value that my model have)

How it should be done? Plus for an answer that also deals with the biding (which will probably be an issue as well)

Était-ce utile?

La solution

Using MonoRail Select Using Enum I did something like this:

#foreach($item in EnumToPairs(typeof(MyEnum)))
    $Form.RadioField("myModel.MyEnumProperty", $item.First)
    $Form.LabelFor("myModel.MyEnumProperty", $item.Second)
#end

And then on the controller, you would just use ARDataBind or DataBind normally.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top