Foros del Web » Programando para Internet » PHP » Frameworks y PHP orientado a objetos »

error Smarty+QuickForm2

Estas en el tema de error Smarty+QuickForm2 en el foro de Frameworks y PHP orientado a objetos en Foros del Web. bueno como esl nombre dice tengo un error con smarty y quickfrom bueno esto intentando hacer un formulario pero me manda este error Call to ...
  #1 (permalink)  
Antiguo 26/10/2013, 19:46
 
Fecha de Ingreso: marzo-2013
Mensajes: 3
Antigüedad: 11 años, 1 mes
Puntos: 0
Pregunta error Smarty+QuickForm2

bueno como esl nombre dice tengo un error con smarty y quickfrom bueno esto intentando hacer un formulario pero me manda este error

Call to protected HTML_QuickForm2_Renderer_Array::__construct() from invalid context

Aclaro estoy siguendo el ejemplo que encontre en un tema aqui mismo de Casius

Gracias de antemano y espero me puedan ayudar y perdon por las molestias que pueda causar

les dejo el codigo del tpl y el php

Código PHP:
require_once "HTML/QuickForm2.php";
      require_once 
'HTML/QuickForm2/Renderer/Array.php';
      require_once 
'Smarty/libs/Smarty.class.php';

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

      
// Create the template object
      
$tpl=& new Smarty();
      
$tpl->template_dir 'templates';
      
$tpl->compile_dir  'templates_c';

      
// Create the renderer object    
      
$renderer =& new HTML_QuickForm2_Renderer_Array($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('test.tpl');
      
      
//echo $form;
      
?> 

y el tpl
Código HTML:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
  <!--  $Id: smarty-guide.tpl,v 1.1 2005/03/03 19:26:54 kae Exp $ -->
  <html>
  <head>
    <title>Smarty template demonstration</title>
    <style type="text/css">
      {literal}   
        th {
          text-align: right;
        }
      {/literal}
    </style>
  </head>

  <body>
  <h2>
    {$form_data.header.hdrTesting}
  </h2>
  <form {$form_data.attributes}>
    <!-- Display the fields -->
    <table>
      <tr>
        <th>{$form_data.txtFirstName.label}</th>
        <td>{$form_data.txtFirstName.html}</td>
        <th>{$form_data.txtLastName.label}</th>
        <td>{$form_data.txtLastName.html}</td>
      </tr>
      <tr>
        <th>{$form_data.txtAge.label}</th>
        <td>{$form_data.txtAge.html}</td>
        <th>{$form_data.txtTelephone.label}</th>
        <td>{$form_data.txtTelephone.html}</td>
      </tr>
      <!-- Display the buttons -->
      <tr>
        <td align="center" colspan="4">
          {$form_data.btnClear.html}&nbsp;{$form_data.btnSubmit.html}
        </td>
      </tr>
      <!-- Display the copyright -->
      <tr>
        <td style="font-size:11px; color: navy; text-align: center" colspan="4">
          &copy;2004 Tiger Computing Ltd
        </td>
      </tr>
    </table>
  </form>
  </body>
  </html> 

Etiquetas: form, php
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 15:17.