PHP Classes

one form.tpl file

Recommend this page to a friend!

      PHP Forms Class with HTML Generator and JavaScript Validation  >  PHP Forms Class with HTML Generator and JavaScript Validation package blog  >  Locating addresses on...  >  All threads  >  one form.tpl file  >  (Un) Subscribe thread alerts  
Subject:one form.tpl file
Summary:one form.tpl file
Messages:4
Author:chris lejeune
Date:2006-12-04 17:06:30
Update:2006-12-04 19:54:16
 

  1. one form.tpl file   Reply   Report abuse  
Picture of chris lejeune chris lejeune - 2006-12-04 17:06:30
Hi Manuel,

Thanks again for the excellent class.

My current setup is this:

contact.php, contact_form.tpl, contact.tpl

This is the two lines of code I have in contact.php, and other .php files.
$CallingFile = basename($_SERVER['SCRIPT_NAME'], ".php");
include('main_form_properties.inc');

$CallingFile is then the object name in 'main_form_properties.inc'.
Through some switches I assemble the form properties based on the calling script. I then output the form through Smarty. So one file ('main_form_properties.inc') contains all the properties for the modules forms.

I would like to have one form.tpl file and one .tpl that captures and outputs all the forms. Right now I have a different from.tpl file for each form; I would like to have only one form.tpl. So form.tpl will have an {input name="FormArray[]"}, or so.
A FormArray element will be a different depending on $CallingFile.

Can I do this with your class? If yes, how?

Thank You,

chris




  2. Re: one form.tpl file   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2006-12-04 17:32:30 - In reply to message 1 from chris lejeune
What you can do is to call the class function GetInputs and iterate over the array of public inputs that it returns in your template.

Alternatively, you can use the form_layout_vertical plug-in to layout a set of inputs vertically, one per line. It does not require any external HTML or Smarty templates. It uses default HTML templates for each input row, but you can override those templates for all inputs and even add special rows for custom layout. See the test_auto_layout_form.php example script.

  3. Re: one form.tpl file   Reply   Report abuse  
Picture of chris lejeune chris lejeune - 2006-12-04 19:50:09 - In reply to message 2 from Manuel Lemos
Manuel,

Thank you for the super fast response.

My previous forms class didn't have the GetInputs class function. I downloaded the latest and it's there. I'll try both of you suggestions.

Thank You,

chris

  4. Re: one form.tpl file   Reply   Report abuse  
Picture of chris lejeune chris lejeune - 2006-12-04 19:54:16 - In reply to message 2 from Manuel Lemos
Manuel,

Thank you for the super fast response.

My previous forms class didn't have the GetInputs class function. I downloaded the latest and it's there. I'll try both of you suggestions.

Thank You,

chris