The most flexible and powerful way to build a form on iOS.
Form came out from our need to have a form that could share logic between our iOS apps and our web clients, we found that JSON was the best way to achieve this.
Form includes the following features:
- Multiple groups: For example you can have a group for personal details and another one for shipping information
- Field validations: We support
required
,maximum length
,minimum length
andformat
(regex). We also support many field types, for example:text
,number
,phone_number
,email
,date
,name
and more - Custom sizes: Total
width
is handled as 100% whileheight
is handled in chunks of 85 px - Custom fields: You can register your custom fields, it's pretty simple (our basic example includes how to make an
image
field) - Formulas or computed values: We support fields that contain generated values from other fields
- Targets:
Hide
,show
,update
,enable
,disable
orclear
a field using a target. It's pretty powerful, you can even set a condition for your target to run - Dropdowns: Generating dropdowns is as easy as adding values to your field, values support
default
flags, targets (in case you want to trigger hiding a field based on a selection), string values or numeric values and subtitles (in case you want to hint the consequences of your selection)
Don't forget to check our Basic Demo for a basic example on how to use Form.
At the moment Form only supports the iPad, support for the iPhone will come soon.
Usage
Basic Form
This is the required form to create a basic form with a first name field.
JSON
[
{
"id":"group-id",
"title":"Group title",
"sections":[
{
"id":"section-0",
"fields":[
{
"id":"first_name",
"title":"First name",
"type":"name",
"size":{
"width":30,
"height":1
}
}
]
}
]
}
]
In your iPad app
// AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Don't forget to set your style, or use the default one if you want
[FORMDefaultStyle applyStyle];
//...
}
// UICollectionViewController subclass
- (FORMDataSource *)dataSource
{
if (_dataSource) return _dataSource;
_dataSource = [[FORMDataSource alloc] initWithJSON:self.JSON
collectionView:self.collectionView
layout:self.layout
values:nil
disabled:NO];
return _dataSource;
}
- (void)viewDidLoad
{
[super viewDidLoad];
self.collectionView.dataSource = self.dataSource;
}
Contributing
Please check our playbook for guidelines on contributing.
Credits
Hyper made this. We're a digital communications agency with a passion for good code, and if you're using this library we probably want to hire you.
License
Forms is available under the MIT license. See the LICENSE file for more info.