Skip to content

4. NeatForm Guidelines

Elly Kitoto edited this page Apr 12, 2020 · 2 revisions

Below are the guidelines for neat form. Please read this section before beginning to author forms.

General

  • Neat form uses Easy Rules Engine. Check out their wiki to learn more how rules engine works
  • Neat form uses snake case convention for naming of attributes
  • Every calculation rule name must end _calculation in the rules file
  • Every skip logic rule must end with _visibilityin the rules file
  • Every form must have at least one step.
  • Neat form uses Neat stepper libary for the steps which cannot be overridden at the moment.
  • You can override neat form views with your own implementations just before building the forms. The FormBuilder uses an internal map (view_type -> ViewClass) to create views.
  • Neat form uses snake_case on the JSON. And every attribute -> value is a string.

Note: Skip logic refers to hiding and showing of views based on certain conditions as specified on rules.

Views/Fields

  • Every fields has an optional attributed called metadata or meta_data that you can use to pass extra information to the field. This extra data will be binded to the final result of the field
  • All the field attributes are wrapped in properties and the should closely match the name used on XML with exception on custom views.
  • The attribute "required_status": "Yes:You error message" is used to denote that a field is required. Required fields will have a red asterisk appended to them. The value is colon separated with the first part being the status (Yes/true or No/false) and the second part the error message.
  • subjects/binding_fields attribute is used to create dependency map for the rules engine. When applied to a field, the field begins to watch for changes in the values of the fields listed on the attribute.
  • calculations/dependent_calculations/calculation_fields is used to map calculations to the current field. Whenever this field's value changes then invoke the calculations listed on this attribute.

Rules

Neat form creates a dependency tree for rules, i.e mapping a field with rules that are supposed to be fired when the value of the field(s) that the current field is watching upon are changed.

Simple interest calculation example

The formula for calculating simple interest is:

Simple interest = P×i×n

where:

P = Principle i = interest rate n = term of the loan

Thus, if simple interest is charged at 5% on a $10,000 loan that is taken out for three years, the total amount of interest payable by the borrower is calculated as $10,000 x 0.05 x 3 = $1,500.

In the above example suppose we have 3 views for capturing the principle amount (principle), interest rate (interest_rate) and term of loan (loan_term); neat form will build the following dependency tree to watch for changes from the three fields. Meaning each time the principle amount/interest rate/term of loan fields are updated then the simple interest is recalculated by the rules engine.

interest -> principle, interest_rate, loan_term