3lvis / Form

The most flexible and powerful way to build a form on iOS

Home Page:http://hyper.no

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Use case difference between Sections and Fields

jasper-ch-chan opened this issue · comments

Not an issue, but I am struggling to understand the use case difference between a Section and a Field.

Assume I have a simple form of 2 text fields: First Name and Last Name. Suppose also I want the First Name cell to be on the top, and the Last Name cell to be directly below it.

Presently, you can implement the JSON as 1 section with 2 fields of 100% width each, or 2 sections with 1 field each.

Which is the most correct answer?

Hi @jasper-ch-chan,

A section groups a bunch of fields that represent the same category. For example, first name and last name belong to the category "Personal details" if you had a field called "Monthly salary" could go into "Contract details", etc.

The main difference is that Form takes your fields and groups them using a header:

basic-form

For your example, I think having both in the same section makes more sense :)

Hi @3lvis

Doesn't that sound like Groups then? So are you saying that section doesn't really play any real UI aspect to it, but rather its just a data container for fields?

@jasper-ch-chan My bad, was mistaking sections with groups, a section draws a separator line.

@jasper-ch-chan You might use a section when you don't want the fields to take up the full-width of the screen but still wish to start a new area for fields:

form-section

Another benefit of putting fields into sections is that you can act on the entire section rather than each field individually. This can save a lot of time and code:

[FORMTarget hideSectionTargetWithID:@"development-section"];

@jeffleeismyhero @3lvis
Thanks for your explanation. I see what the difference is between the two now.