Example #1
0
 public function previewAction()
 {
     $form_post_array = isset($_POST['frmb']) ? $_POST : false;
     if ($form_post_array != false) {
         K_Loader::load('formbuilder', APP_PATH . '/plugins');
         $form_builder = new Formbuilder($form_post_array);
         $this->putAjax($form_builder->generate_html());
     } else {
         $this->putAjax('ERROR');
     }
 }
 public static function salvar()
 {
     $objetoFormulario = new Formulario();
     $objetoFormulario->selecionarPorId($_GET['id']);
     $form = new Formbuilder($_POST);
     $html = $form->generate_html(Configuracao::$baseUrl . '../salvar.html');
     $json = json_encode($form->get_encoded_form_array());
     $dom = new DOMDocument('1.0', 'utf-8');
     $dom->loadHTML(mb_convert_encoding($html, 'html-entities', 'utf-8'));
     $formulario = $dom->getElementsByTagName('form')->item(0);
     $ol = $dom->getElementsByTagName('ol')->item(0);
     $inputHidden = $dom->createElement('input');
     $inputHidden->setAttribute('type', 'hidden');
     $inputHidden->setAttribute('name', 'id_evento');
     $inputHidden->setAttribute('value', $objetoFormulario->fkEvento);
     $formulario->insertBefore($inputHidden, $ol);
     //$inputHidden = $dom->createElement('input');
     //$inputHidden->setAttribute('type', 'hidden');
     //$inputHidden->setAttribute('name', 'id_ingresso');
     //$inputHidden->setAttribute('value','$INGRESSO');
     //$formulario->insertBefore($inputHidden, $ol);
     $inputHidden = $dom->createElement('input');
     $inputHidden->setAttribute('type', 'hidden');
     $inputHidden->setAttribute('name', 'id_formulario');
     $inputHidden->setAttribute('value', $_GET['id']);
     $formulario->insertBefore($inputHidden, $ol);
     $inputHidden = $dom->createElement('input');
     $inputHidden->setAttribute('type', 'hidden');
     $inputHidden->setAttribute('name', 'passo_ordem');
     $inputHidden->setAttribute('value', $_GET['passo']);
     $formulario->insertBefore($inputHidden, $ol);
     //$inputHidden = $dom->createElement('input');
     //$inputHidden->setAttribute('type', 'hidden');
     //$inputHidden->setAttribute('name', 'quantidade_ingressos');
     //$inputHidden->setAttribute('value','$QUANTIDADE');
     //$formulario->insertBefore($inputHidden, $ol);
     $html = $formulario->ownerDocument->saveHtml();
     $passo = new Passo();
     $passo = $passo->getByFormularioPasso($_GET['id'], $_GET['passo']);
     $passo->html = $html;
     $passo->estrutura = $json;
     $passo->salvar();
     $resposta = new stdClass();
     $resposta->html = $html;
     echo @json_encode($resposta);
 }
Example #3
0
 public function test_GenerateHtml_customAction()
 {
     $form = new Formbuilder($this->_container);
     $this->_form_html = sprintf($this->_form_html, 'fake/url/to/post/to');
     $this->assertEquals($this->_form_html, $form->generate_html('fake/url/to/post/to'));
 }
Example #4
0
<?php

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->generate_html();
//------------------------------------------------------------------------------
// 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($form_data);
//$form->connect();
//$form->save_form();
//------------------------------------------------------------------------------
// Here's the example output of get_encoded_form_array()
$dom = new DOMDocument();
$dom->loadHTML($for_db);
$form = $dom->getElementsByTagName('form')->item(0);
$ol = $dom->getElementsByTagName('ol')->item(0);
$inputHidden = $dom->createElement('input');
$inputHidden->setAttribute('type', 'hidden');