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

smarty.request.ARRAYvariable

 
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 -> General
View previous topic :: View next topic  
Author Message
cyberlot
Smarty n00b


Joined: 06 Aug 2003
Posts: 1

PostPosted: Wed Aug 06, 2003 3:22 pm    Post subject: smarty.request.ARRAYvariable Reply with quote

I use arrays for my form variables, which allow me to pass that array directly into a database function that parses and inserts the array.

so

Code:

<input type=text name=info[row1]>
<input type=text name=info[row2]>


How would I access those in smarty.. I tried
Code:

{$smarty.request.info.row1}
and
{$smarty.request.info[row1]}


Each time I get reference errors.
Back to top
View user's profile Send private message
CirTap
Smarty Pro


Joined: 04 Jun 2003
Posts: 106

PostPosted: Wed Aug 06, 2003 9:29 pm    Post subject: Reply with quote

Hi,
1) are row1 and row2 numerical indexes?

if they are numeric, you could use
Quote:
{foreach $smarty.request.info key=iKey item=iValue}
Item {$iKey} has value {$iValue}
{/foreach}


2) or is the HTML actually looking like this
Code:
<input type=text name=info[[b]'tbl_field1'[/b]]>
<input type=text name=info[[b]'tbl_field2'[/b]]>

(hmm, I have to try this ...<g>)

then the item array becomes a hash/assoc array, and this one should work:
Field 1: {$smarty.REQUEST.info.tbl_field1}
Field 2: {$smarty.REQUEST.info.tbl_field2}
but I "guess" this requires a valid keyname, info[row1] is not, but info['row1']. Usually PHP handles this (although I consider this bad habit), but maybe Smarty is a bit more picky about this.

Have fun,
CirTap
Back to top
View user's profile Send private message
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 -> General 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