For Programmers: Free Programming Magazines  


Home > Archive > PHP Smarty Templates > December 2004 > {php} tags and multidimensional arrays in smarty.









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author {php} tags and multidimensional arrays in smarty.
Rob Adams

2004-12-14, 9:02 pm

I have a situation where I need to display a variable number of shipping
address forms, depending on user input. Since there is no built in for or
while loop, I used {php}tags to setup a loop through the address forms.

Everything is working great, except one part:
{select name=sstate test=$ship.$addrcnt.state}


This is a custom function I've made, to help put the text 'selected' in the
right spot on select/option fields. Anyway, you can see what I'm trying to
do here, but it obviously doesn't work. Any way I can make this work?
Below is the line in context:

<select name="ship[{$addrcnt}][state]"
class="listbox" >
<option value=""> Select State </option>
{select name=sstate test=$ship.$addrcnt.state}
{foreach from=$states item=state}
<option value="{$state->code}" {select name=sstate
value=$state->code}>{$state->state}</option>
{/foreach}
</select>

Thanks for any help.

-- Rob
Rob Adams

2004-12-14, 9:02 pm

Sorry... was having problems posting. Not sure why it came across twice
though...

-- Rob
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com