All pastes #134923 Raw Edit

mantang0

public text v1 · immutable
#134923 ·published 2006-08-16 16:22 UTC
rendered paste body
  <?php
      require_once "HTML/QuickForm.php";
      require_once 'HTML/QuickForm/Renderer/ArraySmarty.php';
      require_once '/usr/local/lib/php/Smarty/Smarty.class.php';

      $form = new HTML_QuickForm('frmTest', 'get');
      $form->addElement('header', 'hdrTesting', 'Testing Smarty');
      $form->addElement('text', 'txtFirstName', 'First name?');
      $form->addElement('text', 'txtLastName', 'Last name?');
      $form->addElement('text', 'txtAge', 'Age?');
      $form->addElement('text', 'txtTelephone', 'Telephone number?');
      $form->addElement('reset', 'btnClear', 'Clear');
      $form->addElement('submit', 'btnSubmit', 'Submit');
      if ($form->validate()) {
          # If the form validates then freeze the data
          $form->freeze();
      }

      // Create the template object
      $tpl =& new Smarty;
     $tpl->caching = false;
     $tpl->clear_all_cache();
$tpl->template_dir = '/var/www/new.gami.com/smarty/templates';
$tpl->compile_dir = '/var/www/new.gami.com/smarty/templates_c';
$tpl->cache_dir = '/var/www/new.gami.com/smarty/cache';
$tpl->config_dir = '/var/www/new.gami.com/smarty/configs';      

      // Create the renderer object	
      $renderer =& new HTML_QuickForm_Renderer_ArraySmarty($tpl);

      // build the HTML for the form
      $form->accept($renderer);

      // assign array with form data
      $tpl->assign('form_data', $renderer->toArray());

      // parse and display the template
      $tpl->display('smarty1.tpl');
  ?>