Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build a form mapper #1

Closed
brunow opened this issue Feb 26, 2012 · 1 comment
Closed

Build a form mapper #1

brunow opened this issue Feb 26, 2012 · 1 comment

Comments

@brunow
Copy link
Owner

brunow commented Feb 26, 2012

Configuration will be similar to cell mapping. With any object you would be able to create a table view with form fields.

@brunow
Copy link
Owner Author

brunow commented Mar 24, 2012

Here is an example of what I'm working on:

self.formModel = [BKFormModel formTableModelForTableView:self.tableView];

Movie *movie = [Movie movieWithTitle:@"Star Wars: Episode VI - Return of the Jedi"
                             content:@"After rescuing Han ..."];

movie.shortName = @"SWEVI";
movie.suitAllAges = [NSNumber numberWithBool:YES];
movie.numberOfActor = [NSNumber numberWithInt:4];
movie.genre = [Genre genreWithName:@"Action"];
movie.releaseDate = [NSDate date];

[BKFormMapping mappingForClass:[Movie class] block:^(BKFormMapping *formMapping) {
    [formMapping sectiontTitle:@"Information section" identifier:@"info"];
    [formMapping mapAttribute:@"title" title:@"Title" type:BKFormAttributeMappingTypeText];
    [formMapping mapAttribute:@"releaseDate" title:@"ReleaseDate" type:BKFormAttributeMappingTypeDatePicker];
    [formMapping mapAttribute:@"suitAllAges" title:@"All ages" type:BKFormAttributeMappingTypeBoolean];
    [formMapping mapAttribute:@"shortName" title:@"ShortName" type:BKFormAttributeMappingTypeLabel];
    [formMapping mapAttribute:@"numberOfActor" title:@"Number of actor" type:BKFormAttributeMappingTypeInteger];

    [formMapping mapAttribute:@"choice" title:@"Choices" selectValuesBlock:^NSArray *(id value, id object, NSInteger *selectedValueIndex){
        *selectedValueIndex = 1;
        return [NSArray arrayWithObjects:@"choice1", @"choice2", nil];
    }];

    [self.formModel registerMapping:formMapping];
}];

[self.formModel loadFieldsWithObject:movie];

Screenshot of form
http://blog.brunowernimont.be/data/images_hosting/form_mapping_1.png
http://blog.brunowernimont.be/data/images_hosting/form_mapping_2.png
http://blog.brunowernimont.be/data/images_hosting/form_mapping_3.png

@brunow brunow closed this as completed May 12, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant