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

Name of option as associative array

 
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 -> Tips and Tricks
View previous topic :: View next topic  
Author Message
radecek
Smarty n00b


Joined: 05 May 2010
Posts: 1

PostPosted: Wed May 05, 2010 7:23 am    Post subject: Name of option as associative array Reply with quote

Hi,

I need make form with many options ({html_options..}). Each options have name and index, becouse I load and save data throw database. But I have problem with name and index. I cant use:
Code:
{html_options name=d[type][$s.optionName] options=$s.sponsorType selected=$s.type}


When I use name='d[type][$s.optionName]' name of element is d[type][$s.optionName]. $s.optionName isnt var, but string.

Name of element must be: d[type][abcdefgh].

Index of d[type][abcdefgh] isnt number but sha1 code.

Do you know haw can I solve this problem? I have temporary and bad solutions:
php:
Code:

$smarty->assign("sponsor", "type[".$logoSha1."]");


template:
Code:

{html_options name=$sponsor ...}


Thx for reply
Back to top
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Wed May 05, 2010 1:55 pm    Post subject: Reply with quote

Code:
{html_options name="d[type][`$s.optionName`]" options=$s.sponsorType selected=$s.type}


or:

Code:
<select name="d[type][{$s.optionName}]">
  {html_options options=$s.sponsorType selected=$s.type}
</select>
Back to top
View user's profile Send private message Visit poster's website
topwzp
Guest





PostPosted: Mon Jun 07, 2010 8:16 am    Post subject: Reply with quote

Good one dude..keep doing nice work
Back to top
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 -> Tips and Tricks 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