RE: [PEAR] QuickForm with Smarty

From: Date: Sat, 19 Apr 2003 05:30:46 +0000
Subject: RE: [PEAR] QuickForm with Smarty
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-4952@lists.php.net to get a copy of this message
Hi, In order to use Smarty with Quickform someone already have a way to work with these classes. I've found this (see below), on PHP Smarty General list. Regards, Mac ..The PhP_KiD ------------------------------------------------------ From: Thomas Schulz Date: Fri Dec 6 15:44:02 2002 Subject: Re: Section and Associative Arrays Malcolm Hutty schrieb in php.smarty.general: > Is it possible to get a section to iterate over an associative array? > > I've got one deeply multi-dimensional associative array which > describes all the data I want Smarty to render into the template. As a > new Smarty user, I assumed this would be a common/key use for Smarty. My answer is a sample. I use Smarty to render the multi-dimensional associative array which is delivered by PEAR's HTML_Quickform->toArray(): Array ( [validationScript] => [attributes] => action="/index.php" method="POST" target="_self" [requiredNote] => wird ben?t! [sections] => Array ( [0] => Array ( [header] => Registrierung (1.Schritt) [elements] => Array ( [username] => Array ( [required] => 1 [html] => <input size="12" name="username" type="text" /> [value] => [type] => text [frozen] => [label] => Ihre Nutzerkennung ) [fullname] => Array ( [required] => 1 [html] => <input size="24" name="fullname" type="text" /> [value] => [type] => text [frozen] => [label] => Ihr vollst?iger Name: ) [email] => Array ( [required] => 1 [html] => <input size="40" name="email" type="text" /> [value] => [type] => text [frozen] => [label] => Ihre E-mail Adresse: ) [re_email] => Array ( [required] => [html] => <input size="40" name="re_email" type="text" /> [value] => [type] => text [frozen] => [label] => Wiederholung: ) [save] => Array ( [required] => [html] => <input name="save" value="Weiter" type="submit" /> [value] => Weiter [type] => submit [frozen] => [label] => ) ) ) ) ) The Smarty code to format this array: ------------------------------------- {if $frm.validationScript} <script language="javascript"> <!-- {$frm.validationScript} //--> </script> {/if} <table> <form{$frm.attributes}> {foreach item=sec from=$frm.sections} <tr> <td class="titel">{$sec.header}</td> </tr> <tr> <td class="content"> <table border="0" cellspacing="0" cellpadding="0"> <tr> <td colspan="2" > {if $frm.errors} <b><font color="{#err#}"> Bitte korrigieren... Angaben! </font></b> {/if} </td> </tr> {foreach key=name item=element from=$sec.elements} <tr> <td> {$element.label} </td> <td> {if $frm.errors[$name]} <font color="{#err#}">{$frm.errors[$name]}</font> <br /> {/if} {$element.html} </td> </tr> {/foreach} </table> </td> </tr> {/foreach} </form> </table> Hope this is not too complex ;-) ThS. -> -----Mensaje original----- -> De: Jon Wood [mailto:jon@jellybob.co.uk] -> Enviado el: Viernes, 18 de Abril de 2003 19:24 -> Para: ThE PhP_KiD -> CC: pear-general@lists.php.net -> Asunto: Re: [PEAR] QuickForm with Smarty -> -> -> On Fri, 2003-04-18 at 23:01, ThE PhP_KiD wrote: -> > Hi ! -> > -> > There is a way to use QuickForm package with -> > Smarty templates ? -> If your using the latest release (3.0.1) you can write a renderer for -> it... take a look at the IT_* renderers for (vague) ideas, and the -> Renderer.php base class for everything you can do with a renderer. -> -> And if you come up with something send a patch... Smarty support would -> be great. -> -> Jon -> > -> > I've browse examples on "doc" QuickForm folder -> > but I don't have idea about how to ensamble -> > QuickForm with Smarty. -> > -> > Can anybody give me a example, idea or link ? -> > -> > Thanks...! -> > -> > Mac -> > ...The PhP_KiD. -> > ->

« previous php.pear.general (#4952) next »