PhantomJS and jQuery.dForm

I’ve been using this combination for a few projects recently.
jQuery dForm is a really nice little library that takes so much hassle out of creating and editing forms.

It effectively stores forms as JSON objects which you can save to a database field, read in to edit the form and save again.

Of course, you want forms to work whether the user has javascript on or not – and that’s where PhantomJS comes in.

PhantomJS is basically a headless Webkit browser – the same engine that powers Google Chrome and Apple Safari. Point it at a page that renders the form created with jQuery.dForm, grab the html that’s rendered and either publish that html out to a file or store the html in different database field.

 

Form Logic

As a web application developer, one of the main things I deal with are forms.

At work I do a lot of conference registration forms.
While these mostly share a lot of commonalities, at the same time they are all unique and have unique fields and requirements that are specific to that particular conference, so I end up writing a lot of custom form logic for each one.

With “form logic” I mean 2 different things – firstly javascript logic to show & hide different elements based on previous answers (so if they choose University accommodation show bookable nights), and also PHP logic for what to do with and how to handle and process form submission.

Recently, for a different project I’ve been working on a way to structure logic as a JSON. The intention being that the client could potentially design the logic for their own forms using a UI similar to what you find in email clients for message filtering.

The potential of giving people the tools to help themselves, with me only having to get involved if they need something that not currently supported is an exciting one.
I’ve recently published the project to github here. If anyone is interested in collaborating on that project please contact me at contact[at]alanevans.me.