<?php

// This is an arry of fake form values that should be coming from your
// database, or data storage system. This is simply defined here for
// example purposes only.
//$fake_db_vals = Array( 'form_structure' => '[{"cssClass":"input_text","required":"undefined","values":"First Name"},{"cssClass":"input_text","required":"undefined","values":"Last Name"},{"cssClass":"textarea","required":"undefined","values":"Bio"},{"cssClass":"checkbox","required":"undefined","title":"What\'s on your pizza?","values":{"2":{"value":"Extra Cheese","baseline":"undefined"},"3":{"value":"Pepperoni","baseline":"undefined"},"4":{"value":"Beef","baseline":"undefined"}}}]');
require 'Formbuilder/Formbuilder_pdo.php';
$form = new Formbuilder_pdo();
$form->connect();
$fake_db_vals = $form->loadFormRecord($get_form_id);
require 'Formbuilder/Formbuilder.php';
// At this stage, we want to pass in the POST value
// containing the form. In this example we simply
// pass POST directly, but DO NOT use POST without
// proper security in place.
// The get_encoded_form_array() method returns an array that should be
// used to store the values in the database. This array
// is also what's passed to the class when rendering
// or editing the form.
$form_data = isset($_POST['frmb']) ? $_POST : false;
$form = new Formbuilder($form_data);
$for_db = $form->get_encoded_form_array();
$for_db_raw = $form->open311_form();
//------------------------------------------------------------------------------
// OR, you could use our database object with some database connection
// information to automatically save everything to the database.
// You could do that like so:
require 'Formbuilder/Formbuilder_pdo.php';
//$form_data = isset($_POST['frmb']) ? $_POST : false;
$form = new Formbuilder_pdo($for_db);
$form->connect();
$form->save_form();
//$form->save_form_open311();
//------------------------------------------------------------------------------
// Here's the example output of get_encoded_form_array()
print_r($for_db_raw);
//Array
//(
//    [form_id] => 1
//    [form_structure] => [{"cssClass":"input_text","required":"undefined","values":"First Name"},{"cssClass":"input_text","required":"undefined","values":"Last Name"},{"cssClass":"textarea","required":"undefined","values":"Bio"},{"cssClass":"checkbox","required":"undefined","title":"What's on your pizza?","values":{"2":{"value":"Extra Cheese","baseline":"undefined"},"3":{"value":"Pepperoni","baseline":"undefined"},"4":{"value":"Beef","baseline":"undefined"}}}]
//)
<?php

require 'Formbuilder/Formbuilder.php';
require 'Formbuilder/Formbuilder_pdo.php';
$form = new Formbuilder_pdo();
$form->connect();
$forms_list = $form->loadForms();