On 02.08.2010, at 19:27, Richard Dyce wrote:
> Just a pre-re-invent-the-wheel inquiry... Does anyone have an example of 
> macros for formatting form fields in phptal?
> I have an older framework which create field objects based on the data and 
> type, and populates them from a simple array:
> e.g.
> <?php
>  $fields = array(
>    'id'        => array('label'=>'',      'type'=>'hidden', 'value'=>2),
>    'name' => array('label'=>'Name',  'type'=>'text',   'value'=>'John Smith'),
>    'user'    => array('label'=>'Owner', 'type'=>'select', 
> 'valuelist'=>array(1,2,3), 'value'=>2)
>    );
> ?>
> It seems daft me to duplicate the logic twice over, and it appears that 
> phptal might be able to handle it with some repeats and templating. But 
> before I tie myself in knots over this, has anyone already done it, or tried 
> it and found the gotcha ;-)

If you already have framework that works, then most pragmatic solution would be 
to let it generate HTML, and then output it literally in PHPTAL:

${structure form_html}

I don't have any code to generate form from such structure, but it seems quite 
doable with TAL.

regards, Kornel

PHPTAL mailing list

Reply via email to