Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Handy Template if you user PEAR:HTML_QuickForm

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Tips and Tricks
View previous topic :: View next topic  
Author Message
Dasher
Smarty Pro


Joined: 16 May 2007
Posts: 124
Location: Italy

PostPosted: Fri May 18, 2007 7:34 pm    Post subject: Handy Template if you user PEAR:HTML_QuickForm Reply with quote

If you're a user of PEAR:HTML_QuickForm or HTML_QuickForm_Controller (for generating wizard pages in php) - then this is the template I find handy.

form-display.tpl
Code:

<!---------------------------------------------------------------------------------------------------------------->
<!-- A generic template for displaying the output of PEAR:HTML_QuickForm & HTML_QuickForm_Renderer_Array      -->
<!-- Use this template with something similar to:                                                -->
<!--                {include file="form-display.tpl" form=$aVar}                                 -->
<!---------------------------------------------------------------------------------------------------------------->

<!-- First Apply any javascript -->
{$form.javascript}

<table border="0" class="editform" align="center">
    <form{$form.attributes}>{$form.hidden}

   <!--  Loop through any sections -->   
    {foreach item=sec key=i from=$form.sections}
        <tr class="formSectionHeaderRow">
            <td class="formSectionHeaderCell" colspan="2">
            <b>{$sec.header}</b>
            </td>
        </tr>

      <!-- Now loop through the elements within this section -->
        {foreach item=element from=$sec.elements}
           
            {if $element.type eq "submit" or $element.type eq "reset"}
                {if not $form.frozen}
               <tr class="formSectionSubmitRow">   
                  <td class="formSectionSubmitCell">&nbsp;</td>
                  <td align="right" class="formSubmitCell">{$element.html}</td>
               </tr>
                {/if}
            {else}
                <tr class="formSectionDataRow">
               {if $element.type eq "textarea"}               
                  <td colspan="2" class="formSectionDataCell" >
                     {if $element.required}
                        <font color="red">*</font>
                     {/if}
                     <b>{$element.label}</b><br />
               {else}
                  <td align="right" valign="top" class="formSectionDataCell">
                     {if $element.required}
                        <font color="red">*</font>
                     {/if}
                     <b>{$element.label}:</b>
                  </td>
                  <td class="formSectionDataCell">
               {/if}
               {if $element.error}
                  <div class="formDataErrorText">{$element.error}<br/></div>
               {/if}
               {if $element.type eq "group"}
                  {foreach key=gkey item=gitem from=$element.elements}
                     {$gitem.label}{$gitem.html}
                     {if $gitem.required}
                        <font color="red">*</font>
                     {/if}                           
                     {if $element.separator}
                        {cycle values=$element.separator}
                     {/if}
                  {/foreach}
               {else}
                  {if $element.type eq "static"}
                     <div class="formSectionDataStatic">{$element.html}</div>
                  {else}
                           {$element.html}
                     
                  {/if}
               {/if}
               {if isset($element.label_note) }
                  <div class="formSectionDataNote" >{$element.label_note}</div>
               {/if}
                  </td>
                </tr>
           
            {/if}
        {/foreach}   
    {/foreach}
   
    {if $form.requirednote and not $form.frozen}
      <tr class="formSectionRequiredNoticeRow">
         <td class="formSectionRequiredNoticeCell">&nbsp;</td>
         <td valign="top" class="formSectionRequiredNoticeCell">
            {$form.requirednote}
         </td>
      </tr>
    {/if}
   
    </form>   
</table>


The original version came originally from the example with the HTML_QuickForm_Renderer_Array and it's been beefed up to me more generic.

It's battle hardened and has been used extensively.

Any questions - don't be afraid to ask.. Smile
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
crespowu
Smarty n00b


Joined: 29 Dec 2007
Posts: 1

PostPosted: Sat Dec 29, 2007 8:35 am    Post subject: Reply with quote

Cool tempalte.Very easy-to-use,especially for beginners. Very Happy
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Tips and Tricks All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP