Php – Fastest way to build form – PHP/jQuery/CodeIgniter

codeigniterjqueryphp

There are tons of ways to handle forms in general, but I'm wondering if anyone has a solid solution that they use for almost all of their apps, something can build out forms quickly and include all types of form elements.

What I'm currently using is simply CI's built-in form validation and then building out a form, but even with this, I feel like it takes too long… any suggestions?

Best Solution

There is a jQuery plugin (called "dform") which take JSON input to build a form dynamically. I have been using this for a while now.

Please take a look at the following URL:
http://neyeon.com/p/jquery.dform/doc/files2/readme-txt.html

Quick Usage:

var formdata =
{
"action" : "index.html",
"method" : "get",
"elements" :
[
    {
        "name" : "textfield",
        "label" : "Label for textfield",
        "type" : "text",
        "value" : "Hello world"
    },
    {
        "type" : "submit",
        "value" : "Submit"
    }
]
};

$("#myform").buildForm(formdata);

// Or to load the form definition via AJAX
$("#myform").buildForm("http://example.com/myform.json");