PHP Classes

Smarty template behaviour in form templates

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  >  How to Show Google Ma...  >  All threads  >  Smarty template behaviour in form...  >  (Un) Subscribe thread alerts  
Subject:Smarty template behaviour in form...
Summary:if tags don't seem to be working
Messages:4
Author:Flip
Date:2012-08-03 21:38:05
Update:2012-08-04 19:45:19
 

  1. Smarty template behaviour in form...   Reply   Report abuse  
Picture of Flip Flip - 2012-08-03 21:38:05
Hi,

I have a question regarding the smarty template behaviour in form templates (which run through prefilter.form.php).
Is it true that some standard smarty functionality does not work anymore?

{if 'a'=='a'}What's happening?{/if}
In a little test case i made the {if}{/if} tags don't seem to be working. (if anyone want i could make a testcase that i can upload somewhere).

When looking at the prefilter.form.php code i see that a regular expression search is being done at some tags: include|include_php|if|else|elseif.

I don't quite understand the regular expression being done, but from what i do understand is that they are being replaced.

This could be my mistake and limited understanding, just i'd like a second opinion because if this is true then it means that a lot of smarty template engine features are not available within the part of the HTML form. Which would require me to find a big workaround (making multiple form templates sticked together maybe?) or i will have to drop either smarty or forms generation & validation class. Which would be a shame since i'm already heavily incorperating the two packages into my project.

Thanks for the help

  2. Re: Smarty template behaviour in form...   Reply   Report abuse  
Picture of Flip Flip - 2012-08-03 21:40:20 - In reply to message 1 from Flip
Eh i feel a bit silly as right after posting this i realised the form.tpl example has actualy if conditions in it. I'll post again when i find out more.

  3. Re: Smarty template behaviour in form...   Reply   Report abuse  
Picture of Flip Flip - 2012-08-04 16:43:03 - In reply to message 2 from Flip
The weirdest thing ...

$smarty->registerFilter('pre', 'smarty_prefilter_form');
$output = $smarty->fetch("form.tpl");
$smarty->unregisterFilter('pre', 'smarty_prefilter_form');

the $output variable contains all my missing information. For some reason the template is broken apart where one part contains normal form template data and the other part containing all the sections that use an if.

So my form displays as normal but "What's happening?" (as a test) is not displayed within the form template. But $output containts "What's happening?".

  4. Re: Smarty template behaviour in form...   Reply   Report abuse  
Picture of Flip Flip - 2012-08-04 19:45:19 - In reply to message 3 from Flip
I made a little test in form.tpl

Line 4: <td bgcolor="#000080" style="border-style: none;"><font color="#ffffff"><b>{$title}</b></font></td>

I used the place of {$title} to put some code to test.

<td bgcolor="#000080" style="border-style: none;"><font color="#ffffff"><b>{if 'a'=='a'}Test 1{/if} Test 2{$title}</b></font></td>

What happens ...
everything between <b></b> is not displayed.

My project runs on Smarty 3.1.8 & formsgeneration-2012-03-26.

Please someone confirm this bug