HOW TO USE FORMBUILDER
===========================================================
The files we've setup in this package are designed to assist
you in understanding / working with this system. We've explained
a bit more details in this document. Please let us know
if anything needs to be corrected.
Including Javascript
------------------------------------------
The first step is to include the proper javascript files.
Then, you need to activate the form builder class on a single div within your page.
The save url is the relative/absolute to which the POST data should be sent when
the user activates the save process.
The load url is the relative/absolute address that will provide the xml response
for loading.
Including / Using PHP Class
------------------------------------------
The first step in your application is to include the class:
require('Formbuilder/Formbuilder.php');
The class is independent of any database so you need to handle saving the form
structure/hash, as well as storing/emailing the live form submission.
Saving Jquery Form
--------------------------------
To save the POST request from the jquery object, just invoke the following:
// Get the POST data.
$form_data = isset($_POST['ul']) ? $_POST['ul'] : false;
// Pass the data to the class
$form = new Formbuilder($form_data);
// Return the array for saving to a database
$for_db = $form->get_encoded_form_array();
The $for_db variable is an array and will contain a hash value, and the
serialized form value. Save these two values to your database. They both need
to be provided to the class for rendering/processing the form in the same array
format.
Loading for Jquery Form
--------------------------------
The jquery plugin is awaiting xml or JSON. You need to pass the hash and
form structure saved in your database as an array, just as it was saved.
$form = new Formbuilder($fake_db_vals);
$form->render_xml();
or
$form->render_json();
Render Form HTML
--------------------------------
To render the actual form html for users/visitors to fill out, you
need to provide the hash/structure array (same as previous section) to the
following methods.
$form = new Formbuilder($fake_db_vals);
$form->render_html('example-submit.php');
The render html function will generate and print the html of the entire form.
By default the css should be very flexible for your display needs, but you
may always extend the formbuilder class to provide your own output logic.
The argument to the render_html function is the action for the form. It may be a
relative or absolute URL.
Process Form Submission
--------------------------------
When the user fills out the form, we will try to validate it as best as we can
and then we'll provide success/failure along with an array of the results.
Again, you must pass the hash/form structure array to the formbuilder class.
$form = new Formbuilder($fake_db_vals);
$results = $form->process();
The process function will check all fields for any basic validation. The returned
array will include a boolean indicator for success/failure, an html unordered list
of any validation errors, and an array of all valid results.
You may use this array in constructing your email, saving back to a database,
etc.