nicklockwood/FXForms — pull request #7 by bartvandendriessche (2014-03-11 09:35:02+00:00)
Title: Add FXFormFieldValueTransformer option

This adds a `FXFormFieldValueTransformer` option.

This makes it a bit easier to work with string enums, such as e.g. locals.

I have a `Customer` form which has a `region` field. My supported regions are e.g.:

`@[@"BE-VLG", @"BE-BRU", @"BE-WAL", @"NL", @"DE", @"FR", @"LU"]`

But I would like to show them as:

`@[@"Flanders", @"Brussels", @"Wallonia", @"Netherlands", @"Germany", @"France", @"Luxemburg"]`

With this patch, I can define the region field as follows:

```Objective-C
@{
FXFormFieldKey: @"region",
FXFormFieldTitle: NSLocalizedString(@"Region", nil),
FXFormFieldOptions: @[@"BE-VLG", @"BE-BRU", @"BE-WAL", @"NL", @"DE", @"FR", @"LU"],
FXFormFieldValueTransformer: [NSValueTransformer valueTransformerForName:ISO33612ValueTransformerName],
}
```

As a side-note, I'm wondering if you'd be interested in allowing `FXOptionsForm`s to work with a datasource. I think it would be an awesome option to have for complexer option forms.

In my region example, it would allow me to group `Flanders`, `Brussels` and `Wallonia` under the `Belgium section`.