[PHPTAL] Nesting commands

Federico frugnale at gmail.com
Tue Apr 18 10:20:45 CEST 2006


Ross Riley wrote:
> Hello.
> Wondering if any of you have come across the following problem.
>
> I want to use metal:use-macro to place a form input into a form, the idea
> being that I loop through an indeterminate number of elements and include
> the correct snippet depending on a value passed into the template. 
>

fieldGroup/fields is an array of form field objects
Each field object have /info/fieldType property

<tal:block repeat="field fieldGroup/fields">
            <tal:block condition="exists: field/info/fieldType"
metal:use-macro="tpl_form.html/${field/info/fieldType}"></tal:block>
</tal:block>

In tpl_form.html there is a macro for each fieldtype

<tal:block  metal:define-macro="text">
...
</tal:block>

<tal:block  metal:define-macro="textarea">
...
</tal:block>


<tal:block  metal:define-macro="select">
...
</tal:block>

<tal:block  metal:define-macro="checkbox">
...
</tal:block>

and so on...





More information about the PHPTAL mailing list