Latest 2.0.9
Homepage https://github.com/vibze/DARFormBuilder
License LICENSE
Platforms ios 9.0, requires ARC
Authors

Library made to cut corners when making complex forms using UITableView.

Installation using cocoapods

Add pod DARFormBuilder to your podfile and run pod install

Components

Framework provides two types of controllers to build forms. One is basic with less abstraction and another one is more feature-packed.

FormTableViewController

This controller just renders a layout with the cells you provide. You pass it an array of views for them to be rendered in a table. Framework provides a full-featured set of inputs that you can use here.

Example:

let nameField = TextInput()
let titleField = TextInput()
let birthdayField = DateInput()
let likesBoobiesField = SwitchInput()

let tbl = FormTableViewController()
tbl.rows = [
    Row(titleField, nameField),
    Row(birthdayField),
    Row(likesBoobiesField)
]

When using FormTableViewController you are responsible for validating fields and reacting to field values changes. For validation purposes built-in input classes have an errors property which will return a list of error messages for a given field. errors array being empty means that field has passed validation.

List of available cell types

TitleLabelCell

Cell for displaying form titles. Big font, contrasty color.

DescriptionLabelCell

Cell for displaying long texts as descriptions or field clarifications.

StaticValueCell

Label and value for displaying static properties.

NumDialInputCell

Label with number dial. Values can be limited by range.

TextInputCell

Simple textField cell. Can be limited by max length.

DateInputCell

Date picker cell. Supports different input modes.

PhoneInputCell

Phone input cell. Can display a button to pick phone from contact book.

SwitchInputCell

Label with switch view on the right.

ChevronButtonCell

Label with disclosure indicator. Clickable.

DARFormController

Framework offers a convenient controller for building forms. It is instantiated using a JSON configuration file, which can provide fields configurations, initial values and interaction logic.

Below is a JSON config example:

{
    "fields": [
        {
            "key": "name",
            "type": "textInput",
            "label": "Name",
            "maxLength": 60,
            "required": true
        },
        {
            "key": "hideFields",
            "type": "switchInput",
            "label": "Hide Fields",
            "hideFieldsIfChecked": [0]
        },
        ...
    ],
}

Available field types and their settings

textInput

A simple textInput with floating label.

Params:

  • label: String = "" — Placeholder/floating label text
  • keyboardType: String(default|email|phone|number) = "default" — Keyboard type to display for this field
  • maxLength: Int = 0 — Maximum text length
  • required: Bool = false — Field will not pass validation if text is not present

dateInput

Date input with floating label.

Params:

  • label: String = "" — Placeholder/floating label text
  • inputMode: String(datetime|date|time) = "datetime" — Date input mode to display for this field
  • displayFormat: String = "dd.MM.yyyy" — Display date format in unicode format pattern
  • valueFormat: String = “yyyy-MM-dd'T'HH:mm:ss.SSSXXXXX” — Field value format in unicode format pattern
  • required: Bool = false — Field will not pass validation if text is not present

phoneInput

Phone input with floating label.

Params:

  • label: String = "" — Placeholder/floating label text
  • displayFormat: String = "+7 ### ###-##-##" — Phone number formatting mask
  • pickFromContacts: Bool = false — Display pick from contacts button on the field
  • required: Bool = false — Field will not pass validation if text is not present

switchInput

Switch with label on the left.

Params:

  • label: String = "" — Label text
  • hideFieldsIfChecked: [Int] = [] — Form should hide fields at given indices if the switch is on

This framework is built and maintained by DAR Team. Please check out our products!

Latest podspec

{
    "name": "DARFormBuilder",
    "platforms": {
        "ios": "9.0"
    },
    "version": "2.0.9",
    "summary": "A library created to build forms faster",
    "description": "Uses UITableVIew and a set of cells to construct a form for any requirement.",
    "homepage": "https://github.com/vibze/DARFormBuilder",
    "license": "LICENSE",
    "authors": {
        "Viktor Ten": "[email protected]"
    },
    "social_media_url": "https://github.com/vibze",
    "source": {
        "git": "https://github.com/vibze/DARFormBuilder.git",
        "tag": "2.0.9"
    },
    "source_files": "DARFormBuilder/**/*.{swift}",
    "exclude_files": [
        "DARFormBuilderExample/**/*",
        "DARFormBuilderExampleUITests/**/*"
    ],
    "requires_arc": true,
    "pushed_with_swift_version": "3.2"
}

Pin It on Pinterest

Share This