enum
Description
Wpart responsible for handling choices from the pre-defined option sets. During the validation phase, selected value is not converted (it stays a string).
The rendered widgets is a set of <input type="radio" value=Val ... /> Description.
Validation
option |
format |
description |
error message |
choices |
"Val1:Desc1 | Val2:Desc2 | ..." |
Checks if the passed value is on the list of accepted options |
{no_such_enum_value, Input} |
HTML meta-attributes
name |
format |
description |
choices |
"Val1:Desc1 | Val2:Desc2 | ..." |
The choices that could be made. The string is actually a list of possible options: they are separated with a | character (pipe). Each of the choice consists of value that should be set as an HTML value (and passed to the validator) and human-readable description (rendered only on form, not present in the persistence layer). Value and description are separated with : sign (colon). |
chosen |
"Val" |
The default value that will be pre-checked after page rendering. It is overridden during the editing. |
Examples
Records definitions
...
{enum, [{choices, "blue:Blue|red:Red|none:I am color-blind"},
%% other parameters
]
},
...
HTML tag
<wpart:enum choices="erlang:Concurrency|python:Easy to learn|ruby:Easy to read|java:Sloooooow" OTHER_HTML_ATTRIBUTES />
