Enum with custom toString breaks option tag
Bug #588842 reported by
Alison Winters
This bug affects 1 person
Affects | Status | Importance | Assigned to | Milestone | ||
---|---|---|---|---|---|---|
play framework | Status tracked in 1.0 | |||||
1.0 |
Fix Released
|
Undecided
|
Unassigned | |||
1.1 |
Fix Committed
|
Undecided
|
Unassigned |
Bug Description
The CRUD tag enumField.html relies on the enum's toString() to set the value for the option tag. This is incorrect and causes the validation of that field to break because enums can't be automatically bound from a custom toString() value, they need to bind from the .name() value.
I am including a patch that fixes this bug and is fully backward compatible with enums that don't have a custom toString(). This works because the default enum toString() always returns name() anyway.
To post a comment you must log in.
It occurred to me there is also a strong argument to also change "it" to "it.name()" in the following line:
label = messages.get( _property.relation +'.' + it );
That way the lookup value in the messages won't change if the developer changes the behavior of toString().