In my previous post I discussed how WordPress fulfils many of the needs of an application development framework but I noted that it did not support forms.
I have chosen to implement this requirement with Formidable Forms (other forms plug-ins exist). This page is a work in progress and subscribe if you want to receive future updates.
Key features of any forms plugin include,
- Create Forms
- Field validation
- Form validation
- Render forms
- Reuse base data in several Forms
- For example a list of “Products”
- Support for authentication and permissions for CRUD operations
- Reporting
- Import and export
- Ability to trigger business logic on form submission
Reusing base data
In a traditional database backed application one has base-tables and linking-tables (also known as junction tables). The base-tables record the entities identified by their Primary Keys and the linking-tables record the relationships between them by referencing the the Primary Keys (Foreign Key relationship).
Although Formidable Forms does not actually implement physical tables for each form this does not matter. It is possible to implement the concept of a base-table by using the “Data from Entries” option. Once create a form called “Base – Products” (say) and then put a record for each Product into this form. This data can then be used to populate drop-downs elsewhere in the system. One can use either natural keys or if one choose the “store separate values” option in the “Base – Products” table one can use integer or chosen keys. It is always desirable to separate presentation from stored values but I don’t know yet whether integer or chosen keys will work better.
In a database application one can declare referential integrity constraints. It is unreasonable to expect a forms plugin to offer this. However for most applications is not necessary it is not well suited to the rapidly evolving requirements of the typical short-lived WordPress application.
Validation
The key concept in Formidable Forms is the “Field”. This is persisted in a fields table and all its associated meta-data such as validation and security requirements are stored in another table.
A Field can only be rendered in the context of a Form and this has its own security requirements.
Security
It is possible to use WordPress roles to define who can see forms, and fields and who may submit a form.
Import and export
I have tested exporting. I have not yet testing importing fully. I note that when importing events that would be triggered if the record was created manually are not fired. This is probably a good thing.
Reporting
Formidable Forms offers reporting against a single form. Display options include tabular data and graphs.
Formidable Forms does not have a standard report builder. It is not possible to create reports that join data from several into one report or show grouping or roll-up. To some extent this is impeded by the the high degree of normalisation – forms are not individual tables and all fields are stored in a single table.
Full reporting could be enabled by creating a stored procedure that created a run-time view of the pivoted entries in the fields table. For example, it would be called like
select * from form_procedure <form_id>
This stored procedure could be implemented as a plugin. Access to the data should then be done in WordPress-like way. There are some nice JavaScript libraries than can render data tables and reports including SmartClient and Datatables.
Ability to trigger business logic on submission
Formidable Forms has hooks and has published several plug-in extensions including one for Mailchimp list integration. I have not yet tried processing submitted data myself. There are several possible implementations of this including,
- a custom page
- a plugin
- a code snippet in the Code Snippets plug-in
Pingback: Understanding WordPress as a web application framework | Dr James Bayley