Form
The most flexible and powerful way to build a form on iOS
Install / Use
/learn @3lvis/FormREADME
Notice: Form was supported from it's creation back in 2014 until 2021
Moving forward I won't be able to support this project since I'm no longer active in making iOS apps with Objective-C. I'm leaving this repository as a historical reference of what happened during this time. Form had in total 40 releases with almost 19 contributors. If you still support this project I encourage you to fork it and continue the development. I don't feel comfortable with passing this project to another developer due to the fact that I want to have some involvement in all the projects that live under my account. 7 years was a good run, thank you everyone for using this project and thank you to everyone that has contributed to it. Best of luck in your careers and in what this constantly evolving tech world has for all of us.

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,max_length,min_length,min_value,max_valueandformat(regex). We also support many field types, liketext,number,phone_number,email,date,name,count,segment,switch, and more - Custom sizes: Total
widthis handled as 100% whileheightis handled in chunks of 85 px - Custom fields: You can register your custom fields, and it's pretty simple (our basic example includes how to make an
imagefield) - Formulas or computed values: We support fields that contain generated values from other fields
- Targets:
hide,show,update,enable,disableorcleara field using a target. It's pretty powerful, and 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
defaultflags, targets (in case you want to trigger hiding a field based on a selection), string and numeric values or showing additional info (in case you want to hint the consequences of your selection).
Form works both on the iPhone and the iPad.
You can try one of our demos by running this command in your Terminal:
pod try Form
Usage
Basic Form
This are the required steps 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 iOS 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];
//...
}
Subclass
Make sure that your UICollectionViewController is a subclass of FORMViewController.
Targets
Targets are one of the most powerful features of form, and we support to hide, show, update, enable, disable or clear a field using a target. You can even set a condition for your target to run!
In the following example we show how to hide or show a field based on a dropdown selection.

JSON
[
{
"id":"group-id",
"title":"Group title",
"sections":[
{
"id":"section-0",
"fields":[
{
"id":"employment_type",
"title":"Employment type",
"type":"select",
"size":{
"width":30,
"height":1
},
"values":[
{
"id":0,
"title":"Part time",
"default":true,
"targets":[
{
"id":"bonus",
"type":"field",
"action":"hide"
}
]
},
{
"id":1,
"title":"Full time",
"targets":[
{
"id":"bonus",
"type":"field",
"action":"show"
}
]
}
]
},
{
"id":"bonus",
"title":"Bonus",
"type":"number",
"size":{
"width":30,
"height":1
}
}
]
}
]
}
]
Group Collapsibility
Groups have two JSON based collapsibility options: collapsed and collapsible
The collapsed option accepts true or false and defines the default state for the group it is added to. The default is false.
The collapsible option also accepts true or false but defines whether or not a group can be collapsed at all. Defining this option as false, prevents a group from being collapsed on click or with collapseAllGroupsForCollectionView. The default is true.
In your application code, you can also call collapseAllGroupsForCollectionView on the data source to collapse all groups in a collection view.
Counter Fields
To make quick and easy integer adjustments without popping up a keyboard, you can use the count field. It works just like a number field but provides a minus button in the UITextField's leftView and a plus button in the rightView. A tap on either will decrease or increase, respectively, the number by a value of one.
Example JSON
{
"groups":[
{
"id":"counter",
"title":"Counter Example",
"sections":[
{
"id":"counter-example",
"fields":[
{
"id":"guests",
"title":"Present Guests",
"info":"Press minus to decrease, plus to increase",
"type":"count",
"value":0,
"size":{
"width":25,
"height":1
},
"validations":{
"required":true,
"min_value":0,
"max_value":100
}
}
]
}
]
}
]
}
Segment Fields
Segment fields can be used in place of text or select fields where the options are known and limited. Since segment fields do not require multiple taps or keyboard entry, data can be recorded quickly and easily with a single click. The segment field type allows for multiple values like the select field type and supports many of the same attributes.
Example JSON
{
"groups":[
{
"id":"group1",
"title":"Segment Example",
"sections":[
{
"id":"section1",
"fields":[
{
"id":"location",
"title":"Work Location",
"type":"segment",
"styles":{
"font":"AvenirNext-DemiBold",
"font_size":"16.0",
"tint_color":"#CBEDBF"
},
"values":[
{
"id":"in_house",
"title":"In-house",
"info":"In-house employee",
"default":true,
},
{
"id":"remote",
"title":"Remote",
}
],
"size":{
"width":50,
"height":1
}
}
]
}
]
}
]
}
Switch Fields
Switch fields can be used where a true or false response is desired. The switch field type allows for a single value of 0, false, 1, or true. Background and tint color styles are also available for this field.
Example JSON
{
"groups":[
{
"id":"group1",
"title":"Switch Example",
"sections":[
{
"id":"section1",
"fields":[
{
"id":"budget_approved",
"title":"Budget Approved",
"type":"switch",
