Simple Kolibri Forms

Kolibri can create model-view-controller (MVC) forms by using the projector pattern.

It only takes a single line of code to create the form, set up the presentation models, and bind all required listeners such that model and view are always kept in sync. After that, any controller can solely work on the presentation models without ever touching the view.

Only starter.js is application-specific. It sets up the information of what the form should consist of.

Our initial, simplistic form does not contain any business logic and can therefore use the generic SimpleFormController. If we had any business logic, we would put it in a specialized controller and write test cases against that controller. Since we currently have no business logic, we have no specialized controller and no test cases for the logic.

Models, view, and bindings are totally generic and provided by Kolibri. The current generic simpleFormProjector creates a simple form with simple input types. Each such type is created and bound by the generic simpleInputProjector. "Simple" means types that the standard HTML Input element can handle it (no selects or multiple values).

The remaining non-generic thing to test is the general setup. We test this in simpleFormViewTest.js. It also serves as an example of how to do integration testing.

Next Step

If all we ever wanted is a passive web form that we can submit, we wouldn't bother creating controllers, models, binding, and so on. But our investment will pay off as soon as there is interactivity and business logic in our application.

Proceed with work day and let's combine form elements with business rules.