|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
cyberlot Smarty n00b
Joined: 06 Aug 2003 Posts: 1
|
Posted: Wed Aug 06, 2003 3:22 pm Post subject: smarty.request.ARRAYvariable |
|
|
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 |
|
CirTap Smarty Pro
Joined: 04 Jun 2003 Posts: 106
|
Posted: Wed Aug 06, 2003 9:29 pm Post subject: |
|
|
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 |
|
|
|
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
|