Coder Social home page Coder Social logo

Build a form mapper about basekit HOT 1 CLOSED

brunow avatar brunow commented on August 20, 2024
Build a form mapper

from basekit.

Comments (1)

brunow avatar brunow commented on August 20, 2024

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

from basekit.

Related Issues (15)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.